function webform_protected_downloads_send_mail in Webform Protected Downloads 7
Same name and namespace in other branches
- 6 webform_protected_downloads.module \webform_protected_downloads_send_mail()
Send mail to the user with a valid hash so that he can access the download page
Parameters
string $mail:
string $hash:
Return value
void
1 call to webform_protected_downloads_send_mail()
- webform_protected_downloads_process_submissions in ./
webform_protected_downloads.module - Process unprocessed webform submissions
File
- ./
webform_protected_downloads.module, line 878 - This file contains hook declarations and functions for the Webform Protected Downloads module.
Code
function webform_protected_downloads_send_mail($sid, $nid, $mail, $hash) {
global $user;
// choose the language
$language = $user->uid ? user_preferred_language($user) : language_default();
// load the webform node, needed for token replacement
$node = node_load($nid);
// get the submission, including all it's data
$submission = webform_get_submission($nid, $sid);
// the sender address
$from = webform_protected_downloads_get_configuration($nid, 'mail_from', variable_get('site_mail', NULL));
// build the subject
$subject = webform_protected_downloads_get_configuration($nid, 'mail_subject');
$subject = _webform_protected_downloads_token_replace($subject, $node, $hash);
$subject = _webform_filter_values($subject, $node, $submission, $email = NULL, $strict = FALSE, $allow_anonymous = TRUE);
// build the body
$body = webform_protected_downloads_get_configuration($nid, 'mail_body');
$body = _webform_protected_downloads_token_replace($body, $node, $hash);
$body = _webform_filter_values($body, $node, $submission, $email = NULL, $strict = FALSE, $allow_anonymous = TRUE);
$params = array(
'subject' => $subject,
'body' => $body,
'From' => $from,
);
// send the mail
drupal_mail('webform_protected_downloads', 'confirmation', $mail, $language, $params, $from);
}