• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nette / mail / 22359390077

24 Feb 2026 04:11PM UTC coverage: 77.2%. Remained the same
22359390077

push

github

dg
improved phpDoc types

1 of 1 new or added line in 1 file covered. (100.0%)

70 existing lines in 6 files now uncovered.

386 of 500 relevant lines covered (77.2%)

0.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

10.71
/src/Mail/SendmailMailer.php
1
<?php declare(strict_types=1);
2

3
/**
4
 * This file is part of the Nette Framework (https://nette.org)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
namespace Nette\Mail;
9

10
use Nette;
11

12

13
/**
14
 * Sends emails via the PHP internal mail() function.
15
 */
16
class SendmailMailer implements Mailer
17
{
18
        public string $commandArgs = '';
19
        private ?Signer $signer = null;
20
        private bool $envelopeSender = true;
21

22

23
        public function setSigner(Signer $signer): static
24
        {
UNCOV
25
                $this->signer = $signer;
×
UNCOV
26
                return $this;
×
27
        }
28

29

30
        /**
31
         * Sets whether to use the envelope sender (-f option) in the mail command.
32
         */
33
        public function setEnvelopeSender(bool $state = true): static
34
        {
UNCOV
35
                $this->envelopeSender = $state;
×
UNCOV
36
                return $this;
×
37
        }
38

39

40
        /**
41
         * Sends email.
42
         * @throws SendException
43
         */
44
        public function send(Message $mail): void
1✔
45
        {
46
                if (!function_exists('mail')) {
1✔
47
                        throw new SendException('Unable to send email: mail() has been disabled.');
1✔
48
                }
49

UNCOV
50
                $tmp = clone $mail;
×
UNCOV
51
                $tmp->setHeader('Subject', null);
×
52
                $tmp->setHeader('To', null);
×
53

54
                $data = $this->signer
×
UNCOV
55
                        ? $this->signer->generateSignedMessage($tmp)
×
56
                        : $tmp->generateMessage();
×
57
                $parts = explode(Message::EOL . Message::EOL, $data, 2);
×
58

59
                $cmd = $this->commandArgs;
×
UNCOV
60
                if ($this->envelopeSender && ($from = $mail->getFrom())) {
×
61
                        $cmd .= ' -f' . key($from);
×
62
                }
63

UNCOV
64
                $args = [
×
UNCOV
65
                        (string) $mail->getEncodedHeader('To'),
×
66
                        (string) $mail->getEncodedHeader('Subject'),
×
67
                        $parts[1],
×
68
                        $parts[0],
×
69
                        $cmd,
×
70
                ];
71

UNCOV
72
                $res = Nette\Utils\Callback::invokeSafe('mail', $args, function (string $message) use (&$info): void {
×
UNCOV
73
                        $info = ": $message";
×
74
                });
×
75
                if ($res === false) {
×
76
                        throw new SendException("Unable to send email$info.");
×
77
                }
78
        }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc