function uc_order_mail in Ubercart 6.2
Same name and namespace in other branches
- 8.4 uc_order/uc_order.module \uc_order_mail()
- 7.3 uc_order/uc_order.module \uc_order_mail()
Implements hook_mail().
File
- uc_order/
uc_order.module, line 596
Code
function uc_order_mail($key, &$message, $params) {
global $language;
if (isset($message['language'])) {
$original_global_language = drupal_clone($language);
$language = $message['language'];
}
// Build the appropriate message parameters based on the e-mail key.
switch ($key) {
// Setup an e-mailed invoice.
case 'invoice':
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
$message['subject'] = t('Your Order Invoice');
$message['from'] = uc_store_email_from();
$message['body'][] = theme('uc_order', $params['order'], 'admin-mail', variable_get('uc_cust_order_invoice_template', 'customer'));
break;
// Setup a custom e-mail defined by an action on a predicate.
case 'action-mail':
// Assemble an email message from the conditional actions settings.
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
// Perform token replacement on the subject and body.
$subject = token_replace_multiple($params['subject'], $params['replacements']);
$body = token_replace_multiple($params['message'], $params['replacements']);
// Strip newline characters from e-mail subjects.
// TODO: Maybe drupal_mail_send() should do this? -LM
$message['subject'] = str_replace(array(
"\r\n",
"\r",
"\n",
), ' ', $subject);
// Apply an input format to the message body if specified.
if (isset($params['format'])) {
$message['body'][] = check_markup($body, $params['format'], FALSE);
}
else {
$message['body'][] = $body;
}
break;
}
if (isset($message['language'])) {
$language = $original_global_language;
}
}