Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The 'from' parameter is not configurable #8

Open
wants to merge 1 commit into
base: 7.x-2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions message_notify.rules.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ function message_notify_rules_action_info() {
'allow null' => TRUE,
'optional' => TRUE,
),
'from' => array(
'type' => 'text',
'label' => t('The sender of the email'),
'description' => t('The sender of the email. If left empty, the mail will be sent from the site-wide configured address.'),
'default value' => FALSE,
'allow null' => TRUE,
'optional' => TRUE,
),
),
'base' => 'message_notify_rules_process',
);
Expand All @@ -72,7 +80,7 @@ function message_notify_rules_action_info() {
/**
* Action: Process and send Message.
*/
function message_notify_rules_process(Message $message, $save_on_fail, $save_on_success, $rendered_subject_field, $rendered_body_field, $mail = FALSE) {
function message_notify_rules_process(Message $message, $save_on_fail, $save_on_success, $rendered_subject_field, $rendered_body_field, $mail = FALSE, $from = FALSE) {
$options = array(
'save on fail' => $save_on_fail,
'save on success' => $save_on_success,
Expand All @@ -86,7 +94,11 @@ function message_notify_rules_process(Message $message, $save_on_fail, $save_on_
}

if ($mail) {
$options['mail'] = str_replace(array("\r", "\n"), '', $mail);
$options['mail'] = str_replace(array("\r", "\n"), '', $mail);
}

if ($from) {
$options['from'] = $from;
}

message_notify_send_message($message, $options, 'email');
Expand Down
3 changes: 2 additions & 1 deletion plugins/notifier/email/MessageNotifierEmail.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function deliver(array $output = array()) {

$account = user_load($message->uid);
$mail = $options['mail'] ? $options['mail'] : $account->mail;
$from = $options['from'] ? $options['from'] : NULL;

$languages = language_list();
if (!$options['language override']) {
Expand All @@ -28,7 +29,7 @@ public function deliver(array $output = array()) {
// Pass the message entity along to hook_drupal_mail().
$output['message_entity'] = $message;

$result = drupal_mail('message_notify', $message->type, $mail, $lang, $output);
$result = drupal_mail('message_notify', $message->type, $mail, $lang, $output, $from);
return $result['result'];
}

Expand Down
2 changes: 2 additions & 0 deletions plugins/notifier/email/email.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ $plugin = array(
'options' => array(
// Override mail. Don't use the email that is assigned to the user.
'mail' => FALSE,
// Override from. Don't use the site-wide configured address.
'from' => FALSE,
),
// A notifier must define its own view modes.
// Those view modes are later going to be rendered and sent.
Expand Down