function workbench_email_mail_send in Workbench Email 7
Same name and namespace in other branches
- 7.3 workbench_email.module \workbench_email_mail_send()
Determines the emails attributes.
Sets the emails subject / message and sends the email.
Parameters
string $email: The send to email address
object $email_transition: The email transition used for determining the subject / message to retrieve
object $node: The node returned from node_save
1 call to workbench_email_mail_send()
- workbench_email_notification_submit in ./
workbench_email.module - Submit handler for the workflow_email form element.
File
- ./
workbench_email.module, line 234 - Code for the Workbench Email Module.
Code
function workbench_email_mail_send($email, $email_transition, $node) {
$module = 'workbench_email';
$key = 'workflow_email';
$to = $email;
$from = variable_get('site_mail', 'admin@example.com');
if (empty($email_transition->subject) && empty($email_transition->message)) {
drupal_set_message(t('No email template is set, so no email was sent.
Contact your system admin to resolve this issue.'));
return;
}
global $user;
$params['subject'] = $email_transition->subject;
$params['message'] = $email_transition->message;
$params['node'] = $node;
$params['user'] = $user;
$language = language_default();
$send = TRUE;
$result = drupal_mail($module, $key, $to, $language, $params, $from, $send);
if ($result['result'] == TRUE) {
drupal_set_message(t('Your message has been sent.'));
}
else {
drupal_set_message(t('There was a problem sending your
message and it was not sent.'), 'error');
}
}