phpmailer.mimemail.inc in PHPMailer 5.2
File
includes/phpmailer.mimemail.inc
View source
<?php
require_once drupal_get_path('module', 'phpmailer') . '/includes/phpmailer.class.inc';
function mimemail_phpmailer_send($message) {
static $mail;
if (!isset($mail)) {
$mail = new DrupalPHPMailer();
$mail->LE = variable_get('mimemail_crlf', "\n");
}
try {
$address = phpmailer_parse_address($message['sender']);
if ($address[0]['name'] != '') {
$mail->FromName = $address[0]['name'];
}
$mail->From = $address[0]['mail'];
if (variable_get('phpmailer_debug_email', '') === '') {
foreach (phpmailer_parse_address($message['address']) as $address) {
$mail
->AddAddress($address['mail']);
}
if (isset($message['headers']['CC'])) {
foreach (phpmailer_parse_address($message['headers']['CC']) as $address) {
$mail
->AddCC($address['mail']);
}
}
if (isset($message['headers']['BCC'])) {
foreach (phpmailer_parse_address($message['headers']['BCC']) as $address) {
$mail
->AddBCC($address['mail']);
}
}
}
else {
$message['address'] = variable_get('phpmailer_debug_email', '');
$mail
->AddAddress($message['address']);
}
unset($message['headers']['CC'], $message['headers']['BCC']);
$message['headers']['Date'] = $mail
->RFCDate();
if ($message['address']) {
$message['headers']['To'] = $message['address'];
}
$message['headers']['Subject'] = $message['subject'];
$header = mimemail_rfc_headers($message['headers']) . $mail->LE . $mail->LE;
return $mail
->SmtpSend($header, $message['body']);
} catch (phpmailerException $e) {
drupal_set_message(t('Sending of at least one e-mail failed. The error returned was:<br />@error.', array(
'@error' => $e
->getMessage(),
)), 'error');
watchdog('phpmailer', $e
->getMessage(), WATCHDOG_ERROR);
return FALSE;
}
}