summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsun2013-04-11 00:04:53 (GMT)
committer sun2013-04-11 00:04:53 (GMT)
commit068bf33947a30a6169d22d8143d5f9bbd4e9ebc2 (patch)
tree3fbb78fb011794c771991df090ceb3d45126b73a
parentb0fb76c2cbf9e9301f666aa4ac0b89362fe4d87e (diff)
- #1291750 by sun: Updated for new PHPMailer 5.2.5. Requires library update.
-rw-r--r--README.txt8
-rw-r--r--includes/phpmailer.class.inc69
-rw-r--r--includes/phpmailer.drupal.inc2
-rw-r--r--phpmailer.install2
4 files changed, 35 insertions, 46 deletions
diff --git a/README.txt b/README.txt
index ddd14a2..06cf03c 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 7228b9b..827761e 100644
--- a/includes/phpmailer.class.inc
+++ b/includes/phpmailer.class.inc
@@ -147,13 +147,19 @@ class DrupalPHPMailer extends PHPMailer {
}
/**
- * 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 {
* 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;
}
/**
diff --git a/includes/phpmailer.drupal.inc b/includes/phpmailer.drupal.inc
index 1e52912..228930e 100644
--- a/includes/phpmailer.drupal.inc
+++ b/includes/phpmailer.drupal.inc
@@ -90,8 +90,6 @@ function phpmailer_send($message) {
'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 b1e1806..6bd785a 100644
--- a/phpmailer.install
+++ b/phpmailer.install
@@ -30,7 +30,7 @@ function phpmailer_requirements($phase) {
'value' => $t('Missing'),
'severity' => REQUIREMENT_ERROR,
'description' => $t('Please download <a href="@url">PHPMailer for PHP5/6</a>, extract the archive and copy the contents to the following location:<br /><code>@path</code>. Make sure the main file, class.phpmailer.php, is located at<br /><code>@class</code>.', 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',
)),