Skip to content

Commit

Permalink
Merge pull request #2 from mailjet/development
Browse files Browse the repository at this point in the history
Apply Drupal community patch for sending more than one emails in a loop
  • Loading branch information
Ferhan Ismailov authored Mar 6, 2017
2 parents d40cd5a + 47292ec commit 2917810
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions includes/mailjet.mail.inc
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,27 @@ class MailjetSmtpMailSystem implements MailSystemInterface {
$body = $message['params']['body'][0];
}

// If the PHPMailer class is not yet auto-loaded, try to load the library
// using Libraries API, if present.
if (!class_exists('PHPMailer') && function_exists('libraries_load')) {
$library = libraries_load('phpmailer');
if (empty($library) || empty($library['loaded'])) {
watchdog('mailjet', 'Unable to send mail : Libraries API can not load PHPMailer library.', array(), WATCHDOG_ERROR);
if(!class_exists('PHPMailer')) {
// If the PHPMailer class is not yet auto-loaded, try to load the library
// using Libraries API, if present.
if (function_exists('libraries_load')) {
$library = libraries_load('phpmailer');
if (empty($library) || empty($library['loaded'])) {
watchdog('mailjet', 'Unable to send mail : Libraries API can not load PHPMailer library.', array(), WATCHDOG_ERROR);
drupal_set_message(t('Unable to send mail : PHPMailer library does not exist.'), 'error');
return FALSE;
}
}
// Libraries API not present, try manually loading the class file.
elseif (file_exists('sites/all/libraries/phpmailer/PHPMailerAutoload.php')) {
require_once 'sites/all/libraries/phpmailer/PHPMailerAutoload.php';
}
else {
drupal_set_message(t('Unable to send mail : PHPMailer library does not exist.'), 'error');
watchdog('mailjet', 'Unable to send mail : Libraries API and PHPMailer library does not exist .', array(), WATCHDOG_ERROR);
return FALSE;
}
}
// Libraries API not present, try manually loading the class file.
elseif (file_exists('sites/all/libraries/phpmailer/PHPMailerAutoload.php')) {
require_once 'sites/all/libraries/phpmailer/PHPMailerAutoload.php';
}
else {
drupal_set_message(t('Unable to send mail : PHPMailer library does not exist.'), 'error');
watchdog('mailjet', 'Unable to send mail : Libraries API and PHPMailer library does not exist .', array(), WATCHDOG_ERROR);
return FALSE;
}

// Create a new PHPMailer object - autoloaded from registry.
$mailer = new PHPMailer();
Expand Down

0 comments on commit 2917810

Please sign in to comment.