Skip to content

Commit

Permalink
Manually merge my qmail patches for PHPMailer#126
Browse files Browse the repository at this point in the history
Minor cleanups
  • Loading branch information
Synchro committed Oct 29, 2013
1 parent ced3e13 commit 41415a8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
36 changes: 24 additions & 12 deletions class.phpmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ public function isMail()
public function isSendmail()
{
if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
$this->Sendmail = '/var/qmail/bin/sendmail';
$this->Sendmail = '/usr/sbin/sendmail';
}
$this->Mailer = 'sendmail';
}
Expand All @@ -687,9 +687,9 @@ public function isSendmail()
public function isQmail()
{
if (stristr(ini_get('sendmail_path'), 'qmail')) {
$this->Sendmail = '/var/qmail/bin/sendmail';
$this->Sendmail = '/var/qmail/bin/qmail-inject';
}
$this->Mailer = 'sendmail';
$this->Mailer = 'qmail';
}

/**
Expand Down Expand Up @@ -915,9 +915,8 @@ public static function validateAddress($address, $patternselect = 'auto')
/**
* Create a message and send it.
* Uses the sending method specified by $Mailer.
* Returns false on error - Use the ErrorInfo variable to view description of the error.
* @throws phpmailerException
* @return bool
* @return bool false on error - See the ErrorInfo property for details of the error.
*/
public function send()
{
Expand Down Expand Up @@ -1015,17 +1014,18 @@ public function postSend()
// Choose the mailer and send through it
switch ($this->Mailer) {
case 'sendmail':
case 'qmail':
return $this->sendmailSend($this->MIMEHeader, $this->MIMEBody);
case 'smtp':
return $this->smtpSend($this->MIMEHeader, $this->MIMEBody);
case 'mail':
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
default:
if (method_exists($this,$this->Mailer.'Send')) {
$sendMethod = $this->Mailer.'Send';
return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
if (method_exists($this, $this->Mailer.'Send')) {
$sendMethod = $this->Mailer.'Send';
return $this->$sendMethod($this->MIMEHeader, $this->MIMEBody);
} else {
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
}
}
} catch (phpmailerException $e) {
Expand All @@ -1050,9 +1050,17 @@ public function postSend()
protected function sendmailSend($header, $body)
{
if ($this->Sender != '') {
$sendmail = sprintf("%s -oi -f%s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
if ($this->Mailer == 'qmail') {
$sendmail = sprintf("%s -f%s", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
} else {
$sendmail = sprintf("%s -oi -f%s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender));
}
} else {
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
if ($this->Mailer == 'qmail') {
$sendmail = sprintf("%s", escapeshellcmd($this->Sendmail));
} else {
$sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail));
}
}
if ($this->SingleTo === true) {
foreach ($this->SingleToArray as $val) {
Expand Down Expand Up @@ -1627,7 +1635,11 @@ public function createHeader()
}

// sendmail and mail() extract Bcc from the header before sending
if ((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) {
if ((
$this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail'
)
and count($this->bcc) > 0
) {
$result .= $this->addrAppend('Bcc', $this->bcc);
}

Expand Down
17 changes: 17 additions & 0 deletions test/phpmailerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,23 @@ public function testSendmailSend()
$this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
}

/**
* Test sending using Qmail
*/
public function testQmailSend()
{
//Only run if we have qmail installed
if (file_exists('/var/qmail/bin/qmail-inject')) {
$this->Mail->Body = 'Sending via qmail';
$this->BuildBody();
$subject = $this->Mail->Subject;

$this->Mail->Subject = $subject . ': qmail';
$this->Mail->IsQmail();
$this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
}
}

/**
* Test sending using PHP mail() function
*/
Expand Down

0 comments on commit 41415a8

Please sign in to comment.