protected function PHPMailer::sendmailSend
Search API
5.x PHPMailer.php | protected PHPMailer::sendmailSend($header, $body) |
Send mail using the $Sendmail program.
Parameters
string $header The message headers:
string $body The message body:
Return value
bool
Throws
See also
PHPMailer::$Sendmail
1 call to PHPMailer::sendmailSend()
- PHPMailer::postSend in inc/
PHPMailer/ src/ PHPMailer.php - Actually send a message via the selected mechanism.
File
- inc/
PHPMailer/ src/ PHPMailer.php, line 1573
Class
- PHPMailer
- PHPMailer - PHP email creation and transport class.
Namespace
PHPMailer\PHPMailerCode
protected function sendmailSend($header, $body)
{
// CVE-2016-10033, CVE-2016-10045: Don't pass -f if characters will be escaped.
if (!empty($this->Sender) and self::isShellSafe($this->Sender)) {
if ('qmail' == $this->Mailer) {
$sendmailFmt = '%s -f%s';
}
else {
$sendmailFmt = '%s -oi -f%s -t';
}
}
else {
if ('qmail' == $this->Mailer) {
$sendmailFmt = '%s';
}
else {
$sendmailFmt = '%s -oi -t';
}
}
$sendmail = sprintf($sendmailFmt, escapeshellcmd($this->Sendmail), $this->Sender);
if ($this->SingleTo) {
foreach ($this->SingleToArray as $toAddr) {
$mail = @popen($sendmail, 'w');
if (!$mail) {
throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
fwrite($mail, 'To: ' . $toAddr . "\n");
fwrite($mail, $header);
fwrite($mail, $body);
$result = pclose($mail);
$this->doCallback(
($result == 0),
[$toAddr],
$this->cc,
$this->bcc,
$this->Subject,
$body,
$this->From,
[],
);
if (0 !== $result) {
throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
}
}
else {
$mail = @popen($sendmail, 'w');
if (!$mail) {
throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
fwrite($mail, $header);
fwrite($mail, $body);
$result = pclose($mail);
$this->doCallback(
($result == 0),
$this->to,
$this->cc,
$this->bcc,
$this->Subject,
$body,
$this->From,
[],
);
if (0 !== $result) {
throw new Exception($this->lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
}
return true;
}