| 1 |
<?php |
<?php |
| 2 |
// $Id: smtp.module,v 1.17.2.9 2009/11/10 01:34:07 franz Exp $ |
// $Id: smtp.module,v 1.17.2.10 2009/11/10 11:06:14 franz Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 55 |
*/ |
*/ |
| 56 |
function smtp_admin_settings() { |
function smtp_admin_settings() { |
| 57 |
// Override the smtp_library variable. |
// Override the smtp_library variable. |
| 58 |
if (variable_get('smtp_on', 0)) { |
if (module_exists('mimemail')) { |
| 59 |
$smtp_path = drupal_get_filename('module', 'smtp'); |
// don't touch smtp_library |
| 60 |
if ($smtp_path) { |
} |
| 61 |
variable_set('smtp_library', $smtp_path); |
else { |
| 62 |
drupal_set_message(t('SMTP.module is active.')); |
if (variable_get('smtp_on', 0)) { |
| 63 |
|
$smtp_path = drupal_get_filename('module', 'smtp'); |
| 64 |
|
if ($smtp_path) { |
| 65 |
|
variable_set('smtp_library', $smtp_path); |
| 66 |
|
drupal_set_message(t('SMTP.module is active.')); |
| 67 |
|
} |
| 68 |
|
// If drupal can't find the path to the module, display an error. |
| 69 |
|
else { |
| 70 |
|
drupal_set_message(t("SMTP.module error: Can't find file."), 'error'); |
| 71 |
|
} |
| 72 |
} |
} |
| 73 |
// If drupal can't find the path to the module, display an error. |
// If this module is turned off, delete the variable. |
| 74 |
else { |
else { |
| 75 |
drupal_set_message(t("SMTP.module error: Can't find file."), 'error'); |
variable_del('smtp_library'); |
| 76 |
|
drupal_set_message(t('SMTP.module is INACTIVE.')); |
| 77 |
} |
} |
| 78 |
} |
} |
|
// If this module is turned off, delete the variable. |
|
|
else { |
|
|
variable_del('smtp_library'); |
|
|
drupal_set_message(t('SMTP.module is INACTIVE.')); |
|
|
} |
|
| 79 |
|
|
| 80 |
$form['onoff'] = array( |
$form['onoff'] = array( |
| 81 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 238 |
* |
* |
| 239 |
* @see drupal_mail_send() |
* @see drupal_mail_send() |
| 240 |
*/ |
*/ |
| 241 |
function drupal_mail_wrapper($message) { |
function smtp_drupal_mail_wrapper($message) { |
| 242 |
$id = $message['id']; |
$id = $message['id']; |
| 243 |
$to = $message['to']; |
$to = $message['to']; |
| 244 |
$from = $message['from']; |
$from = $message['from']; |
| 697 |
|
|
| 698 |
$mail->SmtpClose(); |
$mail->SmtpClose(); |
| 699 |
return TRUE; |
return TRUE; |
| 700 |
} // End of drupal_mail_wrapper(). |
} // End of smtp_drupal_mail_wrapper(). |
| 701 |
|
|
| 702 |
|
|
| 703 |
|
|
| 813 |
|
|
| 814 |
return $substring; |
return $substring; |
| 815 |
} // End of _smtp_get_substring(). |
} // End of _smtp_get_substring(). |
| 816 |
|
|
| 817 |
|
function drupal_mail_wrapper($message) { |
| 818 |
|
return smtp_drupal_mail_wrapper($message); |
| 819 |
|
} |
| 820 |
|
|
| 821 |
|
|
| 822 |
|
if (module_exists('mimemail')) { |
| 823 |
|
/** |
| 824 |
|
* hook_mailengine for SMTP/MIMEMAIL integration |
| 825 |
|
* |
| 826 |
|
* @param $op |
| 827 |
|
* The operation to perform on the message. |
| 828 |
|
* @param $message |
| 829 |
|
* The message to be sent. |
| 830 |
|
* @return |
| 831 |
|
* Returns TRUE if the operation was successful or FALSE if it was not. |
| 832 |
|
*/ |
| 833 |
|
function smtp_mailengine($op, $message = array()) { |
| 834 |
|
//default values |
| 835 |
|
$message = array_merge( array( |
| 836 |
|
'address' => '', |
| 837 |
|
'subject' => '', |
| 838 |
|
'body' => '', |
| 839 |
|
'sender' => '', |
| 840 |
|
'headers' => '', |
| 841 |
|
), $message); |
| 842 |
|
switch ($op) { |
| 843 |
|
case 'name': |
| 844 |
|
return t('SMTP'); |
| 845 |
|
|
| 846 |
|
case 'description': |
| 847 |
|
return t("SMTP mailing engine using SMTP authenticaion."); |
| 848 |
|
|
| 849 |
|
case 'settings': //not implemented |
| 850 |
|
return FALSE; |
| 851 |
|
|
| 852 |
|
case 'multiple': |
| 853 |
|
case 'single': |
| 854 |
|
case 'send': |
| 855 |
|
if (!is_array($message['address'])) { |
| 856 |
|
$message['address'] = array($message['address']); |
| 857 |
|
} |
| 858 |
|
$status = TRUE; |
| 859 |
|
$message['headers']['Content-Type'] = str_replace('multipart/alternative', 'multipart/mixed', $message['headers']['Content-Type']); |
| 860 |
|
foreach ($message['address'] as $to) { |
| 861 |
|
$status = smtp_drupal_mail_wrapper( |
| 862 |
|
array( |
| 863 |
|
'id' => $message['id'], |
| 864 |
|
'to' => $to, |
| 865 |
|
'from' => $message['headers']['Sender'], |
| 866 |
|
'language' => $message['language'] ? $message['language'] : '', |
| 867 |
|
'subject' => $message['subject'], |
| 868 |
|
'body' => str_replace("\r", '', $message['body']), |
| 869 |
|
'headers' => $message['headers'], |
| 870 |
|
) |
| 871 |
|
) && $status; |
| 872 |
|
} |
| 873 |
|
return $status; |
| 874 |
|
} |
| 875 |
|
return FALSE; |
| 876 |
|
} |
| 877 |
|
|
| 878 |
|
} // if (!module_exists('mimemail')) |
| 879 |
|
|
| 880 |
|
|
| 881 |
|
|