I would like to create an email action which allows a user to send an email where the "reply-to/from" is their registered email address, NOT the site email. I have created a custom module by copying the token-actions module. It works fine with a minor adjustment to deal with VBO issues (see http://drupal.org/node/406600). However, I cannot get the module to send the email from the logged in user. No matter what I try, it sends from the site_mail. I have attached the module, but the relevant code is here (line 144 in attached module):

This sets the "from":
$params['from'] = variable_get('site_mail', ini_get('sendmail_from'));
I have tried to replace it with these, none work, but all send from site_mail:
$params['from'] = variable_get('user_mail', ini_get('sendmail_from'));
$params['from'] = variable_get('mail', ini_get('sendmail_from'));
And, creating extra places in the form for someone to manually enter an address:
$params['from'] = variable_get('from', ini_get('sendmail_from'));

Is there any way to simply get the user email variable? I can't find it anywhere (might be looking in the wrong place).

Thanks!
Maria

CommentFileSizeAuthor
#5 special_actions.txt8.34 KBmariagwyn
#1 special_actions.txt8.21 KBmariagwyn

Comments

mariagwyn’s picture

StatusFileSize
new8.21 KB

oops...forgot the attachment

greggles’s picture

Category: support » feature
Status: Active » Needs work

Could you create this as a patch? http://drupal.org/patch/create

mariagwyn’s picture

A patch? Of the Token_actions module? I can try, but I have NEVER created a patch before (not even sure how, but I will read the directions). What I would really like is an answer to my question, how to send from user email, and THEN, I can create a patch that adds a new action to the already existing actions in the module. If I can figure out how to do this.

m

greggles’s picture

It's not possible to do this, currently. You have to write code to get the "from" address to be something specific like the logged in user.

mariagwyn’s picture

StatusFileSize
new8.34 KB

greggles: giorz made this possible. http://drupal.org/node/406600#comment-1691240

He hacked the token_actions module. I incorporated his changes into my "special" module so that it is not overwritten by token. It looks like the primary step is this:
at line 133: global $user; // GIO-JAYEN aggiunto riferimenti globali ad user.
This called the variable I was missing. Then, two more pieces:

//$params['from'] = variable_get('site_mail', ini_get('sendmail_from')); // GIO-JAYEN tolto riferimento FROM site_admin
  $from = $user->mail; // GIO-JAYEN aggiunto riferimento FROM utente connesso 

// $recipient = token_replace_multiple($context['recipient'], $context); // GIO rimuovi recipient
$recipient = $object->mail; // GIO aggiunto recipient corretto

The first calls the correct variable, the user's mail, and the second corrects Token's inability to register the selected users fro VBO.

He also removed the recipient box completely since it simply pulls from the previous page.

I have attached my version of the special_actions module. I simply have it as a separate module on my site. I tested, and it appears to work exactly right.

cham74’s picture

I also need this functionality, but this hack/patch does not work for me.

Using VBO I need the logged in user to send email not the site admin, and the recipients are selected in the list so it awkward and unnecessary to ask [mail] to be put in the recipients box.

bluegeek9’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)