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:
parent
a2ebfefaad
commit
9ca2bb991c
2 changed files with 18 additions and 50 deletions
34
externals/phpmailer/class.phpmailer-lite.php
vendored
34
externals/phpmailer/class.phpmailer-lite.php
vendored
|
@ -532,36 +532,20 @@ class PHPMailerLite {
|
|||
} else {
|
||||
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
|
||||
}
|
||||
|
||||
if ($this->SingleTo === true) {
|
||||
foreach ($this->SingleToArray as $key => $val) {
|
||||
if(!@$mail = popen($sendmail, 'w')) {
|
||||
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
|
||||
}
|
||||
fputs($mail, "To: " . $val . "\n");
|
||||
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);
|
||||
}
|
||||
$mail = new ExecFuture('%C', $sendmail);
|
||||
$mail->write("To: {$val}\n", true);
|
||||
$mail->write($header.$body);
|
||||
$mail->resolvex();
|
||||
}
|
||||
} else {
|
||||
if(!@$mail = popen($sendmail, 'w')) {
|
||||
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
|
||||
}
|
||||
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);
|
||||
}
|
||||
$mail = new ExecFuture('%C', $sendmail);
|
||||
$mail->write($header.$body);
|
||||
$mail->resolvex();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
34
externals/phpmailer/class.phpmailer.php
vendored
34
externals/phpmailer/class.phpmailer.php
vendored
|
@ -601,36 +601,20 @@ class PHPMailer {
|
|||
} else {
|
||||
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
|
||||
}
|
||||
|
||||
if ($this->SingleTo === true) {
|
||||
foreach ($this->SingleToArray as $key => $val) {
|
||||
if(!@$mail = popen($sendmail, 'w')) {
|
||||
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
|
||||
}
|
||||
fputs($mail, "To: " . $val . "\n");
|
||||
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);
|
||||
}
|
||||
$mail = new ExecFuture('%C', $sendmail);
|
||||
$mail->write("To: {$val}\n", true);
|
||||
$mail->write($header.$body);
|
||||
$mail->resolvex();
|
||||
}
|
||||
} else {
|
||||
if(!@$mail = popen($sendmail, 'w')) {
|
||||
throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL);
|
||||
}
|
||||
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);
|
||||
}
|
||||
$mail = new ExecFuture('%C', $sendmail);
|
||||
$mail->write($header.$body);
|
||||
$mail->resolvex();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue