diff --git a/README.txt b/README.txt
index ddd14a27c51a25488dfcaaa9cc01553e9cde4bd0..06cf03c174e49bf9ecf5548e4d34f9206668e442 100644
--- a/README.txt
+++ b/README.txt
@@ -16,8 +16,8 @@ To submit bug reports and feature suggestions, or to track changes:
* Libraries API module
http://drupal.org/project/libraries
-* PHPMailer for PHP5/6
- http://phpmailer.codeworxtech.com
+* PHPMailer library
+ https://github.com/Synchro/PHPMailer
Optional:
@@ -33,9 +33,9 @@ Optional:
-- INSTALLATION --
-1. Download PHPMailer for PHP5/6 from
+1. Download PHPMailer from
- http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/
+ https://github.com/Synchro/PHPMailer/tags
and extract the following files to the phpmailer subdirectory of your
libraries directory:
diff --git a/includes/phpmailer.class.inc b/includes/phpmailer.class.inc
index b8fd6b4cd006352c9904f0e5ae1f9699bc428dbe..fe4208f96e94dde2c7e28a4f7ea135385ea06dcb 100644
--- a/includes/phpmailer.class.inc
+++ b/includes/phpmailer.class.inc
@@ -147,13 +147,19 @@ class DrupalPHPMailer extends PHPMailer implements MailSystemInterface {
}
/**
- * Destructor.
+ * Overrides PHPMailer::__destruct().
*/
public function __destruct() {
- // Be nice and close the connection when using SMTP keep-alive.
- if ($this->SMTPKeepAlive) {
- $this->SmtpClose();
+ // Disable debug output if SMTP keep-alive is enabled.
+ // PHP is most likely shutting down altogether (this class is instantiated
+ // as a static singleton). Since logging facilities (e.g., database
+ // connection) quite potentially have been shut down already, simply turn
+ // off SMTP debugging. Without this override, debug output would be printed
+ // on the screen and CLI output.
+ if ($this->SMTPKeepAlive && isset($this->smtp->do_debug)) {
+ $this->smtp->do_debug = 0;
}
+ parent::__destruct();
}
/**
@@ -162,47 +168,32 @@ class DrupalPHPMailer extends PHPMailer implements MailSystemInterface {
* Note: messages should not end with a dot.
*/
public function SetLanguage($langcode = 'en', $lang_path = 'language/') {
+ // Retrieve English defaults to ensure all message keys are set.
+ parent::SetLanguage('en');
+
+ // Overload with Drupal translations.
$this->language = array(
- 'provide_address' => t('You must provide at least one recipient e-mail address'),
- 'encoding' => t('Unknown encoding: '),
- 'file_open' => t('Could not open file: '),
- 'signing' => t('Signing error: '),
- 'empty_message' => t('Message body empty'),
- 'tls' => t('SMTP error: STARTTLS not accepted from server'),
- 'authenticate' => t('SMTP error: could not authenticate'),
- 'smtp_connect_failed' => t('SMTP error: could not connect to SMTP host'),
- 'connect_host' => t('SMTP error: could not connect to SMTP host'),
- 'from_failed' => t('The following sender address failed: '), // non-admin
- 'recipients_failed' => t('The following recipient addresses failed: '), // non-admin
- 'data_not_accepted' => t('SMTP error: data not accepted'),
+ 'authenticate' => t('SMTP error: Could not authenticate.'),
+ 'connect_host' => t('SMTP error: Could not connect to host.'),
+ 'data_not_accepted' => t('SMTP error: Data not accepted.'),
+ 'smtp_connect_failed' => t('SMTP error: Could not connect to SMTP host.'),
'smtp_error' => t('SMTP server error: '),
- // Unused messages.
- //'execute' => t('Could not execute: '),
- //'instantiate' => t('Could not instantiate mail() function.'),
-
// Messages used during email generation.
- 'file_access' => t('Could not access file: '),
- 'invalid_address' => t('Invalid address'),
+ 'empty_message' => t('Message body empty'),
+ 'encoding' => t('Unknown encoding: '),
'variable_set' => t('Cannot set or reset variable: '),
- );
- return TRUE;
- }
- /**
- * Assemble the message header.
- *
- * PHPMailer always sets Return-Path to Sender, we want more flexibility.
- */
- public function CreateHeader() {
- $old_sender = $this->Sender;
- if ($this->ReturnPath != '') {
- $this->Sender = $this->ReturnPath;
- }
- $result = parent::CreateHeader();
- // Restore sender for use in MAIL FROM command.
- $this->Sender = $old_sender;
- return $result;
+ 'file_access' => t('File error: Could not access file: '),
+ 'file_open' => t('File error: Could not open file: '),
+
+ // Non-administrative messages.
+ 'from_failed' => t('The following From address failed: '),
+ 'invalid_address' => t('Invalid address'),
+ 'provide_address' => t('You must provide at least one recipient e-mail address.'),
+ 'recipients_failed' => t('The following recipients failed: '),
+ ) + $this->language;
+ return TRUE;
}
/**
@@ -323,8 +314,6 @@ class DrupalPHPMailer extends PHPMailer implements MailSystemInterface {
'Content-Transfer-Encoding' => 'Encoding',
'Sender' => 'Sender',
'Message-ID' => 'MessageID',
- // Custom property.
- // @see DrupalPHPMailer::CreateHeader()
'Return-Path' => 'ReturnPath',
);
foreach ($properties as $source => $property) {
diff --git a/phpmailer.install b/phpmailer.install
index cc7e3313bf8f16b2251e691b07471139cfb69a96..d854b43b1f8717c0528561f44db04604b23b71a9 100644
--- a/phpmailer.install
+++ b/phpmailer.install
@@ -32,7 +32,7 @@ function phpmailer_requirements($phase) {
'value' => $t('Missing'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('Please download PHPMailer for PHP5/6, extract the archive and copy the contents to the following location:
@path
. Make sure the main file, class.phpmailer.php, is located at
@class
.', array(
- '@url' => 'http://sourceforge.net/projects/phpmailer/files/phpmailer%20for%20php5_6/',
+ '@url' => 'https://github.com/Synchro/PHPMailer/tags',
'@path' => $path,
'@class' => $path . '/class.phpmailer.php',
)),