Skip to content

Commit 069845f

Browse files
committed
1 parent a4b3f9e commit 069845f

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

main/inc/lib/phpmailer/class.phpmailer.php

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,35 @@ public function Send() {
594594
* @access protected
595595
* @return bool
596596
*/
597-
protected function SendmailSend($header, $body) {
598-
if ($this->Sender != '') {
599-
$sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
600-
} else {
601-
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
602-
}
597+
protected function SendmailSend($header, $body)
598+
{
599+
if (!(is_file($this->Sendmail) and is_executable($this->Sendmail))) {
600+
throw new phpmailerException(
601+
$this->lang('execute').$this->Sendmail,
602+
self::STOP_CRITICAL
603+
);
604+
}
605+
if (!empty($this->Sender) and $this->validateAddress($this->Sender)) {
606+
if ($this->Mailer == 'qmail') {
607+
$sendmail = sprintf(
608+
'%s -f%s',
609+
escapeshellcmd($this->Sendmail),
610+
escapeshellarg($this->Sender)
611+
);
612+
} else {
613+
$sendmail = sprintf(
614+
'%s -oi -f%s -t',
615+
escapeshellcmd($this->Sendmail),
616+
escapeshellarg($this->Sender)
617+
);
618+
}
619+
} else {
620+
if ($this->Mailer == 'qmail') {
621+
$sendmail = sprintf('%s', escapeshellcmd($this->Sendmail));
622+
} else {
623+
$sendmail = sprintf('%s -oi -t', escapeshellcmd($this->Sendmail));
624+
}
625+
}
603626
if ($this->SingleTo === true) {
604627
foreach ($this->SingleToArray as $key => $val) {
605628
if(!@$mail = popen($sendmail, 'w')) {
@@ -648,7 +671,7 @@ protected function MailSend($header, $body) {
648671
$to = implode(', ', $toArr);
649672

650673
$params = sprintf("-oi -f %s", $this->Sender);
651-
if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) {
674+
if (!empty($this->Sender) and !ini_get('safe_mode') and $this->validateAddress($this->Sender)) {
652675
$old_from = ini_get('sendmail_from');
653676
ini_set('sendmail_from', $this->Sender);
654677
if ($this->SingleTo === true && count($toArr) > 1) {
@@ -704,7 +727,12 @@ protected function SmtpSend($header, $body) {
704727
if(!$this->SmtpConnect()) {
705728
throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL);
706729
}
707-
$smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
730+
731+
if (!empty($this->Sender) and $this->validateAddress($this->Sender)) {
732+
$smtp_from = $this->Sender;
733+
} else {
734+
$smtp_from = $this->From;
735+
}
708736
if(!$this->smtp->Mail($smtp_from)) {
709737
throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
710738
}
@@ -2013,9 +2041,7 @@ public function AddCustomHeader($custom_header) {
20132041
/**
20142042
* Evaluates the message and returns modifications for inline images and backgrounds
20152043
* @access public
2016-
* @param string $message
2017-
* @param string $basedir
2018-
* @return void
2044+
* @return $message
20192045
*/
20202046
public function MsgHTML($message, $basedir = '') {
20212047
preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images);
@@ -2334,4 +2360,3 @@ public function errorMessage() {
23342360
return $errorMsg;
23352361
}
23362362
}
2337-
?>

0 commit comments

Comments
 (0)