Index: smtp.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/smtp/smtp.module,v retrieving revision 1.17.2.8 diff -u -p -r1.17.2.8 smtp.module --- smtp.module 23 Sep 2008 22:03:01 -0000 1.17.2.8 +++ smtp.module 24 Feb 2009 23:19:40 -0000 @@ -55,22 +55,27 @@ function smtp_menu() { */ function smtp_admin_settings() { // Override the smtp_library variable. - if (variable_get('smtp_on', 0)) { - $smtp_path = drupal_get_filename('module', 'smtp'); - if ($smtp_path) { - variable_set('smtp_library', $smtp_path); - drupal_set_message(t('SMTP.module is active.')); + if (module_exists('mimemail')) { + // don't touch smtp_library + } + else { + if (variable_get('smtp_on', 0)) { + $smtp_path = drupal_get_filename('module', 'smtp'); + if ($smtp_path) { + variable_set('smtp_library', $smtp_path); + drupal_set_message(t('SMTP.module is active.')); + } + // If drupal can't find the path to the module, display an error. + else { + drupal_set_message(t("SMTP.module error: Can't find file."), 'error'); + } } - // If drupal can't find the path to the module, display an error. + // If this module is turned off, delete the variable. else { - drupal_set_message(t("SMTP.module error: Can't find file."), 'error'); + variable_del('smtp_library'); + drupal_set_message(t('SMTP.module is INACTIVE.')); } } - // If this module is turned off, delete the variable. - else { - variable_del('smtp_library'); - drupal_set_message(t('SMTP.module is INACTIVE.')); - } $form['onoff'] = array( '#type' => 'fieldset', @@ -233,7 +238,7 @@ function smtp_admin_settings_validate($f * * @see drupal_mail_send() */ -function drupal_mail_wrapper($message) { +function smtp_drupal_mail_wrapper($message) { $id = $message['id']; $to = $message['to']; $from = $message['from']; @@ -377,7 +382,7 @@ function drupal_mail_wrapper($message) { elseif (strpos(drupal_strtolower($value), 'multipart/alternative') !== FALSE) { // The message includes both a plain text and an HTML part. $mail->ContentType = $content_type = 'multipart/alternative'; - + // Get the boundary ID from the Content-Type header. $boundary = _smtp_get_substring($value, 'boundary', '"', '"'); } @@ -512,7 +517,7 @@ function drupal_mail_wrapper($message) { } } break; - + case 'multipart/mixed': // Split the body based on the boundary ID. $body_parts = _smtp_boundary_split($body, $boundary); @@ -672,7 +677,7 @@ function drupal_mail_wrapper($message) { $mail->SmtpClose(); return TRUE; -} // End of drupal_mail_wrapper(). +} // End of smtp_drupal_mail_wrapper(). @@ -709,7 +714,7 @@ function _smtp_boundary_split($input, $b if ($boundary == $bs_check) { $boundary = $bs_possible; } - + $tmp = explode('--'. $boundary, $input); for ($i = 1; $i < count($tmp); $i++) { @@ -788,3 +793,71 @@ function _smtp_get_substring($source, $t return $substring; } // End of _smtp_get_substring(). + +if (!module_exists('mimemail')) { +function drupal_mail_wrapper($message) { + return smtp_drupal_mail_wrapper($message); + } +} + + +if (module_exists('mimemail')) { +/** + * hook_mailengine for SMTP/MIMEMAIL integration + * + * @param $op + * The operation to perform on the message. + * @param $message + * The message to be sent. + * @return + * Returns TRUE if the operation was successful or FALSE if it was not. + */ +function smtp_mailengine($op, $message = array()) { + //default values + $message = array_merge( array( + 'address' => '', + 'subject' => '', + 'body' => '', + 'sender' => '', + 'headers' => '', + ), $message); + switch ($op) { + case 'name': + return t('SMTP'); + + case 'description': + return t("SMTP mailing engine using SMTP authenticaion."); + + case 'settings': //not implemented + return FALSE; + + case 'multiple': + case 'single': + case 'send': + if (!is_array($message['address'])) { + $message['address'] = array($message['address']); + } + $status = TRUE; + $message['headers']['Content-Type'] = str_replace('multipart/alternative', 'multipart/mixed', $message['headers']['Content-Type']); + foreach ($message['address'] as $to) { + $status = smtp_drupal_mail_wrapper( + array( + 'id' => $message['id'], + 'to' => $to, + 'from' => $message['headers']['Sender'], + 'language' => $message['language'] ? $message['language'] : '', + 'subject' => $message['subject'], + 'body' => str_replace("\r", '', $message['body']), + 'headers' => $message['headers'], + ) + ) && $status; + } + return $status; + } + return FALSE; +} + +} // if (!module_exists('mimemail')) + + +