| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id: reroute_email.module,v 1.1.2.2 2007/07/31 23:30:15 kbahey Exp $ |
// $Id: reroute_email.module,v 1.1.2.3 2007/08/01 01:04:53 kbahey Exp $ |
| 4 |
|
|
| 5 |
define('REROUTE_EMAIL_ADDRESS', 'reroute_email_address'); |
define('REROUTE_EMAIL_ADDRESS', 'reroute_email_address'); |
|
define('REROUTE_EMAIL_DEV_NULL', 'reroute_email_dev_null'); |
|
| 6 |
|
|
| 7 |
function reroute_email_menu($may_cache) { |
function reroute_email_menu($may_cache) { |
| 8 |
$items = array(); |
$items = array(); |
| 22 |
} |
} |
| 23 |
|
|
| 24 |
function reroute_email_settings() { |
function reroute_email_settings() { |
|
$form[REROUTE_EMAIL_DEV_NULL] = array( |
|
|
'#type' => 'checkbox', |
|
|
'#title' => t('Disable all mails'), |
|
|
'#default_value' => variable_get(REROUTE_EMAIL_DEV_NULL, FALSE), |
|
|
'#description' => t('Check this to disable all outgoing email from this web site.'), |
|
|
); |
|
|
|
|
| 25 |
$form[REROUTE_EMAIL_ADDRESS] = array( |
$form[REROUTE_EMAIL_ADDRESS] = array( |
| 26 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 27 |
'#title' => t('Email address'), |
'#title' => t('Email address'), |
| 37 |
function reroute_email_mail_alter(&$mailkey, &$to, &$subject, &$body, &$from, &$headers) { |
function reroute_email_mail_alter(&$mailkey, &$to, &$subject, &$body, &$from, &$headers) { |
| 38 |
global $base_url; |
global $base_url; |
| 39 |
|
|
|
if (variable_get(REROUTE_EMAIL_DEV_NULL, FALSE)) { |
|
|
return; |
|
|
} |
|
|
|
|
| 40 |
// Format a message to show at the top |
// Format a message to show at the top |
| 41 |
$msg = "This email was rerouted.\n"; |
$msg = "This email was rerouted.\n"; |
| 42 |
$msg .= "Web site: @site\n"; |
$msg .= "Web site: @site\n"; |
| 47 |
// Prepend to the body of the email |
// Prepend to the body of the email |
| 48 |
$body = t($msg, array('@site' => $base_url, '@to' => $to, '@key' => $mailkey)) . $body; |
$body = t($msg, array('@site' => $base_url, '@to' => $to, '@key' => $mailkey)) . $body; |
| 49 |
|
|
| 50 |
// Now change the $to address to be the one we defined |
// Change the $to address to be the one we defined |
| 51 |
$to = variable_get(REROUTE_EMAIL_ADDRESS, ini_get('sendmail_from')); |
$to = variable_get(REROUTE_EMAIL_ADDRESS, ini_get('sendmail_from')); |
| 52 |
} |
} |
| 53 |
|
|