1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Use ExecFuture to raise sendmail error codes out of PHPMailer

Summary:
Ref T2843. We currently drop any stdout/stderr emitted by sendmail. Instead, use `ExecFuture` so we'll throw an exception with debugging information preserved.

@tido, can you apply this and restart the daemons?

Test Plan: Rests on @tido

Reviewers: tido, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2843

Differential Revision: https://secure.phabricator.com/D5464
This commit is contained in:
epriestley 2013-03-30 15:51:32 -07:00
parent a2ebfefaad
commit 9ca2bb991c
2 changed files with 18 additions and 50 deletions

View file

@ -532,36 +532,20 @@ class PHPMailerLite {
} else { } else {
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
} }
if ($this->SingleTo === true) { if ($this->SingleTo === true) {
foreach ($this->SingleToArray as $key => $val) { foreach ($this->SingleToArray as $key => $val) {
if(!@$mail = popen($sendmail, 'w')) { $mail = new ExecFuture('%C', $sendmail);
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); $mail->write("To: {$val}\n", true);
} $mail->write($header.$body);
fputs($mail, "To: " . $val . "\n"); $mail->resolvex();
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
// implement call back function if it exists
$isSent = ($result == 0) ? 1 : 0;
$this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
if($result != 0) {
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
} }
} else { } else {
if(!@$mail = popen($sendmail, 'w')) { $mail = new ExecFuture('%C', $sendmail);
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); $mail->write($header.$body);
} $mail->resolvex();
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
// implement call back function if it exists
$isSent = ($result == 0) ? 1 : 0;
$this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
if($result != 0) {
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
} }
return true; return true;
} }

View file

@ -601,36 +601,20 @@ class PHPMailer {
} else { } else {
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
} }
if ($this->SingleTo === true) { if ($this->SingleTo === true) {
foreach ($this->SingleToArray as $key => $val) { foreach ($this->SingleToArray as $key => $val) {
if(!@$mail = popen($sendmail, 'w')) { $mail = new ExecFuture('%C', $sendmail);
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); $mail->write("To: {$val}\n", true);
} $mail->write($header.$body);
fputs($mail, "To: " . $val . "\n"); $mail->resolvex();
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
// implement call back function if it exists
$isSent = ($result == 0) ? 1 : 0;
$this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body);
if($result != 0) {
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
} }
} else { } else {
if(!@$mail = popen($sendmail, 'w')) { $mail = new ExecFuture('%C', $sendmail);
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); $mail->write($header.$body);
} $mail->resolvex();
fputs($mail, $header);
fputs($mail, $body);
$result = pclose($mail);
// implement call back function if it exists
$isSent = ($result == 0) ? 1 : 0;
$this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body);
if($result != 0) {
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
}
} }
return true; return true;
} }