本文整理汇总了PHP中drupal_mail函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_mail函数的具体用法?PHP drupal_mail怎么用?PHP drupal_mail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drupal_mail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: emailCollaborators
function emailCollaborators($new_ids, $node)
{
$query = db_select('users', 'u')->condition('uid', $new_ids)->fields('u', array('name', 'mail'));
$result = $query->execute();
foreach ($result as $row) {
$options = array('absolute' => TRUE);
$jobPath = url('node/' . $node->nid, $options);
$jobTitle = $node->title;
global $user;
$inviter = $user->name;
$module = 'tap_job_invite';
$key = 'key';
$email = $row->mail;
$language = language_default();
$params = array();
$from = NULL;
$send = FALSE;
$message = drupal_mail($module, $key, $email, $language, $params, $from, $send);
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
$message['subject'] = "Collaborator invitation at Tap";
$message['body'] = array();
$message['body'][] = "You have invited as a Collaborator by {$inviter} to the job <a href=\"{$jobPath}\">{$jobTitle}</a>. ";
$message['body'][] = "Log in to join the workroom.";
// Retrieve the responsible implementation for this message.
$system = drupal_mail_system($module, $key);
// Format the message body.
$message = $system->format($message);
// Send e-mail.
$message['result'] = $system->mail($message);
}
}
示例2: deliver
/**
* Override parent deliver() function.
*/
public function deliver(array $output = array())
{
$plugin = $this->plugin;
$message = $this->message;
$options = $plugin['options'];
$account = user_load($message->uid);
$mail = !empty($options['mail']) ? $options['mail'] : $account->mail;
$languages = language_list();
if (!$options['language override']) {
$lang = !empty($account->language) && $account->language != LANGUAGE_NONE ? $languages[$account->language] : language_default();
} else {
$lang = $languages[$message->language];
}
// The subject in an email can't be with HTML, so strip it.
$output['message_notify_email_subject'] = strip_tags($output['message_notify_email_subject']);
// Allow for overriding the 'from' of the message.
$from = isset($options['from']) ? $options['from'] : NULL;
$from_account = !empty($message->user->uid) ? user_load($message->user->uid) : $account;
$mimemail_name = variable_get('mimemail_name', t('Atrium'));
$from = array('name' => oa_core_realname($from_account) . ' (' . $mimemail_name . ')', 'mail' => is_array($from) ? $from['mail'] : $from);
// Pass the message entity along to hook_drupal_mail().
$output['message_entity'] = $message;
if (!empty($message->email_attachments)) {
$output['attachments'] = isset($output['attachments']) ? $output['attachments'] : array();
$output['attachments'] = array_merge($message->email_attachments, $output['attachments']);
}
return drupal_mail('message_notify', $message->type, $mail, $lang, $output, $from);
}
示例3: testFromAndReplyToHeader
/**
* Checks the From: and Reply-to: headers.
*/
public function testFromAndReplyToHeader()
{
$language = \Drupal::languageManager()->getCurrentLanguage();
// Use the state system collector mail backend.
\Drupal::config('system.mail')->set('interface.default', 'test_mail_collector')->save();
// Reset the state variable that holds sent messages.
\Drupal::state()->set('system.test_mail_collector', array());
// Send an email with a reply-to address specified.
$from_email = 'Drupal <simpletest@example.com>';
$reply_email = 'someone_else@example.com';
drupal_mail('simpletest', 'from_test', 'from_test@example.com', $language, array(), $reply_email);
// Test that the reply-to email is just the email and not the site name
// and default sender email.
$captured_emails = \Drupal::state()->get('system.test_mail_collector');
$sent_message = end($captured_emails);
$this->assertEqual($from_email, $sent_message['headers']['From'], 'Message is sent from the site email account.');
$this->assertEqual($reply_email, $sent_message['headers']['Reply-to'], 'Message reply-to headers are set.');
$this->assertFalse(isset($sent_message['headers']['Errors-To']), 'Errors-to header must not be set, it is deprecated.');
// Send an email and check that the From-header contains the site name.
drupal_mail('simpletest', 'from_test', 'from_test@example.com', $language);
$captured_emails = \Drupal::state()->get('system.test_mail_collector');
$sent_message = end($captured_emails);
$this->assertEqual($from_email, $sent_message['headers']['From'], 'Message is sent from the site email account.');
$this->assertFalse(isset($sent_message['headers']['Reply-to']), 'Message reply-to is not set if not specified.');
$this->assertFalse(isset($sent_message['headers']['Errors-To']), 'Errors-to header must not be set, it is deprecated.');
}
示例4: deleteUserPage_submit
function deleteUserPage_submit($form, $form_state)
{
global $user;
$UID = $user->uid;
$teams = dbGetTeamsForUser($UID);
// getting teams that are associated with a user
foreach ($teams as $team) {
// looping through these teams
dbKickUserFromTeam($UID, $team['TID']);
// removing the user from these teams
dbRemoveAllUserRoles($UID, $team['TID']);
// ensuring the user doesn't have any role on the team
}
dbRemoveAllEmailsForUser($UID);
dbDisableUser($UID);
$params['feedback'] = stripTags($form_state['values']['misc'], '');
// stripping any "illegal" HTML tags
$params['userName'] = dbGetUserName($UID);
// getting the user name
drupal_mail('users', 'userdeleted', 'croma@chapresearch.com', variable_get('language_default'), $params, $from = null, $send = true);
// sending the user a confirmation mail
drupal_set_message("Your account has been deleted. We're sorry to see you go!");
// message displayed and redirected to front page
drupal_goto('<front>');
}
示例5: mailStatusUpdate
public function mailStatusUpdate($status, $attached)
{
$mail = $this->node->field_email[0]['value'];
$v['subject'] = 'Ваше замечание обработано';
$v['body'] = "Добрый день!\n\n";
$v['body'] .= "Вы писали нам про ошибку в вопросе %1\$s. ";
if ($status == 'resolved') {
$v['body'] .= "Эта ошибка исправлена. В течение 24 часов изменения будут отображены.\n\n";
} elseif ($status == 'accepted') {
$v['body'] .= "Мы признаём эту ошибку. \n\n";
} elseif ($status == 'rejected') {
$v['body'] .= "\n\nНам кажется, что этой ошибки в вопросе нет (или ваше сообщение не было сообщением об ошибке).\n\n";
}
if ($attached) {
$v['body'] .= 'Ваше замечание прикреплено к вопросу.' . "\n\n";
}
$v['body'] .= "Постоянный адрес вашего сообщения -- %2\$s.";
if ($this->oldnode->comment_count) {
$v['body'] .= " По этому адресу вы можете прочитать комментарии";
}
$v['body'] .= "\n\nСпасибо!\n\n-- \nРоман Семизаров\n";
$q = $this->getQuestion();
$v['body'] = sprintf($v['body'], $q->getAbsoluteQuestionUrl(), url('node/' . $this->node->nid, array('absolute' => TRUE)));
drupal_mail('chgk_db', 'issue_status_updated', $mail, language_default(), $v);
}
示例6: libya_cron_subscription_mail
function libya_cron_subscription_mail($data)
{
// subscription node
$mail = $data[0];
$nids = $data[1];
// watchdog('actions', 'Cron subscription vars', func_get_args());
global $siteName, $isMail, $base_url;
$isMail = TRUE;
$body = '<h1 style="font-size:1.25em;">Your alert subscription results from ' . $siteName . '</h1>
<p class="no-margin">The following results match your subscription alert.</p>';
foreach ($nids as $nid) {
$N = node_load($nid);
$content = strip_tags($N->body['und'][0]['value']);
if (strlen($content) > 200) {
$content = substr($content, 0, 200);
}
$CL = strrpos($content, ' ');
$content = substr($content, 0, $CL) . '...';
$body .= '<h2 style="font-size:1.25em;">' . l($N->title, 'node/' . $N->nid, array('attributes' => array('style' => array('text-decoration' => 'none')))) . '</h2><p>' . $content . '</p>
<p>' . t('read more: ') . l($base_url . '/' . drupal_lookup_path('alias', 'node/' . $N->nid), 'node/' . $N->nid, array('absolute' => TRUE)) . '</p>
<hr/>';
}
$data['message'] = 'Mail sent';
$to = $mail['mail'];
$from = variable_get('site_mail', 'mail@libyanwarthetruth.com');
$params = array('body' => $body, 'rand' => $mail['rand'], 'to' => $to);
$sent = drupal_mail('libya', 'subscription_alert_mail', $to, language_default(), $params, $from, TRUE);
}
示例7: hook_invite_send
/**
* Sends the invitation.
*
* Called by the Invite::sendInvite() method.
*
* @param Invite $invite
* The invitation to send.
*/
function hook_invite_send($invite)
{
if (!empty($invite->type_details()->invite_sending_controller['my_module'])) {
global $language;
$entity = entity_metadata_wrapper('invite', $invite);
$params = array('invite' => $invite, 'wrapper' => $entity);
$from = $entity->inviter->mail->value();
drupal_mail('my_module', 'invite', $entity->invitee->mail->value(), $language, $params, $from, TRUE);
}
}
示例8: hook_course_credit_awarded_insert
/**
* Notify modules course credit was awarded.
*
* @param array $record
* The course credit awarded record, including 'ccaid' Course credit awarded
* ID from drupal_write_record().
*
* @see course_credit_award_save()
*/
function hook_course_credit_awarded_insert($record)
{
// Example: send users an email when they are awarded credit.
// TODO Convert "user_load" to "user_load_multiple" if "$record['uid']" is other than a uid.
// To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
// Example: array_shift(user_load_multiple(array(), $record['uid']))
$params['account'] = $account = user_load($record['uid']);
$params['record'] = $record;
$params['subject'] = t("You've got new credit");
drupal_mail('my_module', 'credit_awarded', $account->mail, user_preferred_language($account), $params);
}
示例9: rejectTeam
function rejectTeam($TID)
{
dbRejectTeam($TID);
$UID = dbGetOwnerForTeam($TID);
drupal_mail('adminFunctions', 'teamRejected', dbGetUserPrimaryEmail($UID), variable_get('language_default'), $params = array('teamName' => dbGetTeamName($TID), 'fullName' => dbGetUserName($UID)), $from = NULL, $send = TRUE);
drupal_set_message('The team has been rejected and the team owner has been notified!');
if (isset($_SERVER['HTTP_REFERER'])) {
drupal_goto($_SERVER['HTTP_REFERER']);
} else {
drupal_goto('adminPage');
}
}
示例10: os_poker_report_abuse_form_submit
function os_poker_report_abuse_form_submit($form, &$form_state)
{
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
if ($op == t('Send')) {
$to = variable_get('os_poker_abuse_mail_to', 1);
if (is_numeric($to)) {
$to = user_load($to)->mail;
}
$account = $form['#reporter'];
$from = ($account->profile_nickname ? $account->profile_nickname : $account->name) . '<' . $account->mail . '>';
$params = array('reason' => $form['reason']['#options'][reset(array_filter($form_state['values']['reason']))], 'details' => $form_state['values']['details'], 'reporter' => $form['#reporter'], 'reported' => $form['#reported']);
drupal_mail('os_poker', 'abuse', $to, user_preferred_language($account), $params, $from);
drupal_set_message(t('Your message has been sent.'));
}
}
示例11: guifi_notify_send
/**
* It delivers all the notification messages and empties the queue
*
* @param $send
* If FALSE, the messages won't be sent nor removed from the queue
*
* @return
* Message sent or to be sent, HTML formatted
*/
function guifi_notify_send($send = TRUE)
{
global $user;
$destinations = array();
$messages = array();
// Get all the queue to be processesed, grouping to every single destination
$qt = db_query("\n SELECT *\n FROM {guifi_notify}");
while ($message = db_fetch_array($qt)) {
$messages[$message['id']] = $message;
foreach (unserialize($message['to_array']) as $dest) {
$destinations[$dest][] = $message['id'];
}
}
// For every destination, construct a single mail with all messages
$errors = FALSE;
$output = '';
foreach ($destinations as $to => $msgs) {
$body = str_repeat('-', 72) . "\n\n" . t('Complete trace messages (for trace purposes, to be used by developers)') . "\n" . str_repeat('-', 72) . "\n";
$subjects = t('Summary of changes:') . "\n" . str_repeat('-', 72) . "\n";
foreach ($msgs as $msg_id) {
$subjects .= format_date($messages[$msg_id]['timestamp'], 'small') . ' ** ' . $messages[$msg_id]['who_name'] . ' ' . $messages[$msg_id]['subject'] . "\n";
$body .= format_date($messages[$msg_id]['timestamp'], 'small') . ' ** ' . $messages[$msg_id]['who_name'] . ' ' . $messages[$msg_id]['subject'] . "\n" . $messages[$msg_id]['body'] . "\n" . str_repeat('-', 72) . "\n";
}
$subject = t('[guifi.net notify] Report of changes at !date', array('!date' => format_date(time(), 'small')));
$output .= '<h2>' . t('Sending a mail to: %to', array('%to' => $to)) . '</h2>';
$output .= '<h3>' . $subject . '</h3>';
$output .= '<pre><small>' . $subjects . $body . '</small></pre>';
$params['mail']['subject'] = $subject;
$params['mail']['body'] = $subjects . $body;
$return = FALSE;
if ($send) {
$return = drupal_mail('guifi_notify', 'notify', $to, user_preferred_language($user), $params, variable_get('guifi_contact', $user->mail));
guifi_log(GUIFILOG_TRACE, 'return code for email sent:', $return);
}
if ($return['result']) {
watchdog('guifi', 'Report of changes sent to %name', array('%name' => $to));
} else {
watchdog('guifi', 'Unable to notify %name', array('%name' => $to), WATCHDOG_ERROR);
$errors = TRUE;
}
}
// delete messages
if (!$errors and $send) {
db_query("DELETE FROM {guifi_notify}\n WHERE id in (" . implode(',', array_keys($messages)) . ")");
}
return $output;
}
示例12: deliver
public function deliver(array $output = array())
{
$plugin = $this->plugin;
$message = $this->message;
$options = $plugin['options'];
$account = user_load($message->uid);
$mail = $options['mail'] ? $options['mail'] : $account->mail;
$languages = language_list();
if (!$options['language override']) {
$lang = !empty($account->language) && $account->language != LANGUAGE_NONE ? $languages[$account->language] : language_default();
} else {
$lang = $languages[$message->language];
}
// The subject in an email can't be with HTML, so strip it.
$output['message_notify_email_subject'] = strip_tags($output['message_notify_email_subject']);
// Pass the message entity along to hook_drupal_mail().
$output['message_entity'] = $message;
return drupal_mail('message_notify', $message->type, $mail, $lang, $output);
}
示例13: deleteTeamPage_submit
function deleteTeamPage_submit($form, $form_state)
{
global $user;
$UID = $user->uid;
$TID = $form_state['TID'];
if (dbUserHasPermissionForTeam($user->uid, 'deleteTeam', $TID)) {
dbDeactivateTeam($TID);
dbKickAllUsersFromTeam($TID);
dbRemoveAllRolesFromTeam($TID);
} else {
drupal_set_message('You do not have permission to perform this action.', 'error');
return;
}
// send an email to the CROMA team detailing the team deletion
$params['feedback'] = stripTags($form_state['values']['misc'], '');
$params['userName'] = dbGetUserName($UID);
$params['teamName'] = dbGetTeamName($TID);
$params['teamNumber'] = dbGetTeamNumber($TID);
drupal_mail('teams', 'teamDeleted', 'croma@chapresearch.com', variable_get('language_default'), $params, $from = NULL, $send = TRUE);
drupal_set_message(dbGetTeamName($TID) . " has been deleted.");
drupal_goto('<front>');
}
示例14: execute
/**
* {@inheritdoc}
*/
public function execute($entity = NULL)
{
if (empty($this->configuration['node'])) {
$this->configuration['node'] = $entity;
}
$recipient = $this->token->replace($this->configuration['recipient'], $this->configuration);
// If the recipient is a registered user with a language preference, use
// the recipient's preferred language. Otherwise, use the system default
// language.
$recipient_accounts = $this->storage->loadByProperties(array('mail' => $recipient));
$recipient_account = reset($recipient_accounts);
if ($recipient_account) {
$langcode = $recipient_account->getPreferredLangcode();
} else {
$langcode = language_default()->id;
}
$params = array('context' => $this->configuration);
if (drupal_mail('system', 'action_send_email', $recipient, $langcode, $params)) {
watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
} else {
watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
}
}
示例15: drupal_bootstrap
/**
* Script to send notification emails
*/
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
//_drush_bootstrap_drupal_full();
try {
$completedJobRequests = QueueUtil::getPendingEmailsInfo();
LogHelper::log_debug($completedJobRequests);
} catch (Exception $claimException) {
LogHelper::log_debug("{$logId}: Error while fetching job from queue: " . $claimException);
return;
}
foreach ($completedJobRequests as $request) {
LogHelper::log_info($request);
try {
global $conf;
$dir = variable_get('file_public_path', 'sites/default/files') . '/' . $conf['check_book']['data_feeds']['output_file_dir'];
$file = $dir . '/' . $request['filename'];
$params = array("download_url" => $file, "download_url_compressed" => $file . '.zip', "expiration_date" => date('d-M-Y', $request['end_time'] + 3600 * 24 * 7), "contact_email" => $request['contact_email'], "tracking_num" => $request['token']);
LogHelper::log_debug($params);
$response = drupal_mail('checkbook_datafeeds', "download_notification", $request['contact_email'], null, $params);
LogHelper::log_debug($response);
if ($response['result']) {
QueueUtil::updateJobRequestEmailStatus($request['rid']);
}
} catch (Exception $claimException) {
LogHelper::log_debug("Error while Sending Email Notification: " . $claimException . $params);
return;
}
}