diff --git a/README.md b/README.md index eebc073e..244e7e1c 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Build status: [![Build Status](https://travis-ci.org/PHPMailer/PHPMailer.svg)](h [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/quality-score.png?s=3758e21d279becdf847a557a56a3ed16dfec9d5d)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/) [![Code Coverage](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/badges/coverage.png?s=3fe6ca5fe8cd2cdf96285756e42932f7ca256962)](https://scrutinizer-ci.com/g/PHPMailer/PHPMailer/) +[![Latest Stable Version](https://poser.pugx.org/phpmailer/phpmailer/v/stable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![Total Downloads](https://poser.pugx.org/phpmailer/phpmailer/downloads.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![Latest Unstable Version](https://poser.pugx.org/phpmailer/phpmailer/v/unstable.svg)](https://packagist.org/packages/phpmailer/phpmailer) [![License](https://poser.pugx.org/phpmailer/phpmailer/license.svg)](https://packagist.org/packages/phpmailer/phpmailer) + ## Class Features - Probably the world's most popular code for sending email from PHP! diff --git a/changelog.md b/changelog.md index a467c5d9..1ed9f3af 100644 --- a/changelog.md +++ b/changelog.md @@ -24,6 +24,7 @@ * Improved checks and error messages for missing extensions * Store and report SMTP errors more consistently * Add MIME multipart preamble for better Outlook compatibility +* Provide detailed errors when individual recipients fail ## Version 5.2.9 (Sept 25th 2014) * **Important: The autoloader is no longer autoloaded by the PHPMailer class** diff --git a/class.phpmailer.php b/class.phpmailer.php index 38ff3a6b..245e9bad 100644 --- a/class.phpmailer.php +++ b/class.phpmailer.php @@ -467,7 +467,7 @@ class PHPMailer /** * An array of all kinds of addresses. - * Includes all of $to, $cc, $bcc, $replyto + * Includes all of $to, $cc, $bcc * @type array * @access protected */ @@ -1248,32 +1248,17 @@ class PHPMailer } // Attempt to send to all recipients - foreach ($this->to as $to) { - if (!$this->smtp->recipient($to[0])) { - $bad_rcpt[] = $to[0]; - $isSent = false; - } else { - $isSent = true; + foreach (array($this->to, $this->cc, $this->bcc) as $togroup) { + foreach ($togroup as $to) { + if (!$this->smtp->recipient($to[0])) { + $error = $this->smtp->getError(); + $bad_rcpt[] = array('to' => $to[0], 'error' => $error['detail']); + $isSent = false; + } else { + $isSent = true; + } + $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From); } - $this->doCallback($isSent, array($to[0]), array(), array(), $this->Subject, $body, $this->From); - } - foreach ($this->cc as $cc) { - if (!$this->smtp->recipient($cc[0])) { - $bad_rcpt[] = $cc[0]; - $isSent = false; - } else { - $isSent = true; - } - $this->doCallback($isSent, array(), array($cc[0]), array(), $this->Subject, $body, $this->From); - } - foreach ($this->bcc as $bcc) { - if (!$this->smtp->recipient($bcc[0])) { - $bad_rcpt[] = $bcc[0]; - $isSent = false; - } else { - $isSent = true; - } - $this->doCallback($isSent, array(), array(), array($bcc[0]), $this->Subject, $body, $this->From); } // Only send the DATA command if we have viable recipients @@ -1288,8 +1273,12 @@ class PHPMailer } //Create error message for any bad addresses if (count($bad_rcpt) > 0) { + $errstr = ''; + foreach ($bad_rcpt as $bad) { + $errstr .= $bad['to'] . ': ' . $bad['error']; + } throw new phpmailerException( - $this->lang('recipients_failed') . implode(', ', $bad_rcpt), + $this->lang('recipients_failed') . $errstr, self::STOP_CONTINUE ); } @@ -3449,8 +3438,8 @@ class PHPMailer $to_header = $header; $current = 'to_header'; } else { - if ($current && strpos($header, ' =?') === 0) { - $current .= $header; + if (!empty($$current) && strpos($header, ' =?') === 0) { + $$current .= $header; } else { $current = ''; } diff --git a/class.pop3.php b/class.pop3.php index 984885ff..fe121a1e 100644 --- a/class.pop3.php +++ b/class.pop3.php @@ -130,8 +130,8 @@ class POP3 /** * Simple static wrapper for all-in-one POP before SMTP * @param $host - * @param boolean $port - * @param boolean $tval + * @param integer|boolean $port The port number to connect to + * @param integer|boolean $timeout The timeout value * @param string $username * @param string $password * @param integer $debug_level @@ -140,13 +140,13 @@ class POP3 public static function popBeforeSmtp( $host, $port = false, - $tval = false, + $timeout = false, $username = '', $password = '', $debug_level = 0 ) { $pop = new POP3; - return $pop->authorise($host, $port, $tval, $username, $password, $debug_level); + return $pop->authorise($host, $port, $timeout, $username, $password, $debug_level); } /** diff --git a/class.smtp.php b/class.smtp.php index 8c609d72..81a85d08 100644 --- a/class.smtp.php +++ b/class.smtp.php @@ -631,7 +631,7 @@ class SMTP if ($in_headers and $line == '') { $in_headers = false; } - //We need to break this line up into several smaller lines + //Break this line up into several smaller lines if it's too long //Micro-optimisation: isset($str[$len]) is faster than (strlen($str) > $len), while (isset($line[self::MAX_LINE_LENGTH])) { //Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on diff --git a/examples/contents.html b/examples/contents.html index 9257f6dd..dc3fc667 100644 --- a/examples/contents.html +++ b/examples/contents.html @@ -1,17 +1,17 @@ - + PHPMailer Test -
-

This is a test of PHPMailer.

-
- PHPMailer rocks -
-

This example uses HTML.

-

The PHPMailer image at the top has been embedded automatically.

+
+

This is a test of PHPMailer.

+
+ PHPMailer rocks
+

This example uses HTML.

+

ISO-8859-1 text:

+
diff --git a/examples/contentsutf8.html b/examples/contentsutf8.html new file mode 100644 index 00000000..81a20240 --- /dev/null +++ b/examples/contentsutf8.html @@ -0,0 +1,20 @@ + + + + + PHPMailer Test + + +
+

This is a test of PHPMailer.

+
+ PHPMailer rocks +
+

This example uses HTML.

+

Chinese text: 郵件內容為空

+

Russian text: Пустое тело сообщения

+

Armenian text: Հաղորդագրությունը դատարկ է

+

Czech text: Prázdné tělo zprávy

+
+ + diff --git a/language/phpmailer.lang-am.php b/language/phpmailer.lang-am.php index e1b834d1..ff2a9695 100755 --- a/language/phpmailer.lang-am.php +++ b/language/phpmailer.lang-am.php @@ -23,4 +23,4 @@ $PHPMAILER_LANG['signing'] = 'Ստորագրման սխալ: '; $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP -ի connect() ֆունկցիան չի հաջողվել'; $PHPMAILER_LANG['smtp_error'] = 'SMTP սերվերի սխալ: '; $PHPMAILER_LANG['variable_set'] = 'Չի հաջողվում ստեղծել կամ վերափոխել փոփոխականը: '; -//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; +$PHPMAILER_LANG['extension_missing'] = 'Հավելվածը բացակայում է: '; diff --git a/language/phpmailer.lang-bg.php b/language/phpmailer.lang-bg.php index 7f83abca..6b5c4a11 100644 --- a/language/phpmailer.lang-bg.php +++ b/language/phpmailer.lang-bg.php @@ -23,4 +23,4 @@ $PHPMAILER_LANG['signing'] = 'Грешка при подписва $PHPMAILER_LANG['smtp_connect_failed'] = 'SMTP провален connect().'; $PHPMAILER_LANG['smtp_error'] = 'SMTP сървърна грешка: '; $PHPMAILER_LANG['variable_set'] = 'Не може да се установи или възстанови променлива: '; -//$PHPMAILER_LANG['extension_missing'] = 'Extension missing: '; +$PHPMAILER_LANG['extension_missing'] = 'Липсва разширение: '; diff --git a/language/phpmailer.lang-no.php b/language/phpmailer.lang-no.php index 3d37ba4f..383dd516 100644 --- a/language/phpmailer.lang-no.php +++ b/language/phpmailer.lang-no.php @@ -4,8 +4,8 @@ * @package PHPMailer */ -$PHPMAILER_LANG['authenticate'] = 'SMTP Feil: Kunne ikke authentisere.'; -$PHPMAILER_LANG['connect_host'] = 'SMTP Feil: Kunne ikke koble til SMTP host.'; +$PHPMAILER_LANG['authenticate'] = 'SMTP Feil: Kunne ikke autentisere.'; +$PHPMAILER_LANG['connect_host'] = 'SMTP Feil: Kunne ikke koble til SMTP tjener.'; $PHPMAILER_LANG['data_not_accepted'] = 'SMTP Feil: Data ble ikke akseptert.'; $PHPMAILER_LANG['empty_message'] = 'Meldingsinnholdet er tomt'; $PHPMAILER_LANG['encoding'] = 'Ukjent tegnkoding: '; diff --git a/test/phpmailerTest.php b/test/phpmailerTest.php index b2838ad4..642c87a6 100644 --- a/test/phpmailerTest.php +++ b/test/phpmailerTest.php @@ -149,7 +149,7 @@ class PHPMailerTest extends PHPUnit_Framework_TestCase $eol = "
\r\n"; $bullet_start = '
  • '; $bullet_end = "
  • \r\n"; - $list_start = '