Hi again!
I´ve manage to understand how to send all selected users that are shown inside the views, an email, adding inside the "to" field the [mail] token.
Is there a way that that token could already be there withouth the need for users to paste it?

I wanted it to works somewhat like notifications, without it. :)

Can that be done?

Thanks for your help!!!!

Rosamunda

CommentFileSizeAuthor
#13 special_actions.txt8.34 KBmariagwyn
#11 token_actions.moduleHACK.txt8.37 KBAnonymous (not verified)

Comments

infojunkie’s picture

Hi Rosamunda, I take it that this is related to the first issue you sent: #406296: User views attached to node (viewfield): Send current node by email?. If it is indeed, please copy and paste the body of this issue over there and close this one. Thanks!

Rosamunda’s picture

I think it´s different (kinda), and that´s why I´ve posted it in a different issue. Anyway, it´s perfectly fine if it is considered the same thing, I will do that.

But there I´ve asked if I could (inside a certain node) send that very node to all selected users (that would be shown inside an attached view, combinig VBO with other module´s functionality).

Here I´m asking about the possibility of using the token default email option that comes within VBO, and sending all selected users in the normal default VBO way, but avoid typing the [mail] token to send them.

I´m sorry, my english isn´t quite good, maybe an example would be more clear.

I´ve created a user view that shows all registered users.
I´ve determined that view´s style as Bulk Operations.
I´ve checked only "token_actions_send_email_action" as the selected operation.
It appeared a sending email form with three fields: Recipient - Subject - Body
And then appeared the user´s list created by views with the option of selecting some or all of them.
I select some users there.
The recipients field cannot be left blank, and this is the problem that I´ve encounter:
That field actually sets the recipients of the email! So why is the benefit of selecting the view´s users? apparently none, because it will only send emails to those emails that are pasted inside the recipients field.
So, how can I avoid the need of filling that field and letting Drupal know that I want it to email all selected users.

So my question here is, how could I avoid filling the recipients´ field with [mail]?

Again, I think it´s a different question here and that maybe my sloppy english messed things up, so nobody understood what I really meant :)

Please tell me if you still think it´s the same thing. In that case I will proceed as you´ve told me.

Thanks! Sorry for the mess :)

Rosamunda

infojunkie’s picture

That's a different issue alright :-) I'll check this one too.

infojunkie’s picture

The problem is that the "token_actions_send_email_action" action is designed to be generic, so it requires the user to enter the recipient's email address.

The easiest way to solve your issue is to copy the code for that action into your own module, and to do the following modifications:
* Remove the $form['recipient'] element from token_actions_send_email_action_form().
* In token_actions_send_email_action(), instead of getting the recipient as it's currently done:

<?php
$recipient = token_replace_multiple($context['recipient'], $context);
?>

do the following instead:

<?php
$recipient = $object->mail;
?>

Of course you'll need to change the action name. Hope that helps!

infojunkie’s picture

Status: Active » Fixed

Marking as fixed if you don't mind.

Rosamunda’s picture

Sorry for not replying to this in time and SPECIALLY for not thank you properly.
It worked like a charm, THANK YOU VERY MUCH!
Yup, I really don´t mind to set this as fixed, because indeed, you´ve fixed it and I hope this helps more people as it did to me.
THANKS!
Rosamunda

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

I'm trying to send email from the current user, but the VBO+tokenized email jus send from site_admin email. Any help?

Rosamunda’s picture

And that´s exactly why I´ve started this discussion in the first place. You can use the code that Karim have give us on #4.

mariagwyn’s picture

I am a little confused about how this works. Rosamunda, if you created a unique module to do this, would you mind attaching it so I can see and example? Specifically, I want to send an email (does not need to be tokenized) to users selected in a list, FROM the logged-in user, NOT the site_admin email.

Edit: I have successfully made a special module which sends emails to whomever is checked in the VBO list. however, no matter what I do to the code, the mail is sent from the site email account, not the account of the user who initiated the email. I have tried any number of things. The relevant code appears to be this:

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'));

Any help?
Thanks, Maria

Anonymous’s picture

StatusFileSize
new8.37 KB

try this hack

mariagwyn’s picture

giorez: Grazie Molto!!!

It works perfectly!!!!!! I particularly like that the entire recipient box is removed as this was an odd step for my site users. It removes the need to tell them to put "%author" in the field, which is just gibberish to most people.

I had already made a special module, so I incorporated your changes into the module, though I didn't keep all your changes (kept the longer message text, some descriptions). I have attached the file here.

Again, molti ringraziamenti!

mariagwyn’s picture

StatusFileSize
new8.34 KB

oops...attachment.

Anonymous’s picture

is there any chance to port this into the module for an official release? I don't know how to make a patch, sorry.

cham74’s picture

I am trying the hack in #11 and getting an error message: "Unable to send e-mail. Please contact the site administrator if the problem persists."
I need to be able to send the email to all the selected users from the logged on user and not the system email address

cham74’s picture

Status: Closed (fixed) » Active

Trying to use the hack in the codes above to get the user email creates a no send error for the emails. Why would this stop working id it worked before?

global $user;

//$params['from'] = variable_get('site_mail', ini_get('sendmail_from')); 
  $from = $user->mail;
// $recipient = token_replace_multiple($context['recipient'], $context);
$recipient = $object->mail; 
bojanz’s picture

Status: Active » Closed (fixed)

The last comment is old and talks about non-official code.
Feel free to open a new bug report if you have a reproducible problem with 6.x-1.x-dev.

fnapo’s picture

Version: 6.x-1.5 » 7.x-3.x-dev

Same issue with 7.x, how can I resolve this?
No more "token_actions_send_email_action"

Anonymous’s picture

It seems quite impossible there is no chance 7.x to send email with vbo. any help?

bojanz’s picture

You can use Views Send, or the email action inside a rules component.

Anonymous’s picture

the problem is that I need to use a Views page to send to sms and email messages. I can't create a different list for sms and email messages, so no Views Send usage. Regarding "email action inside a rules component" I don't know what you mean. Thanks a lot for helping me.