0

I have a drupal 7 view diplaying nodes containing an email address field. I would like the user to be able to select multiple rows and then execute an action that simply open his own email client with a new message with all the email addresses in the To: field. I don't want to let users send mass emails via my website but give them an easy way to send emails to many addresses at thew same time via their local email client.

2
  • I don't believe there is a compliant standard for doing this - the standards require one recipient, @, followed by one domain in a mailto link. You can violate the rules using comma separated values in a custom link, but there's a potential the email will fail
    – Geoff
    Commented May 2, 2015 at 14:00
  • Ok but how do I create the link? I tried to create a rule component that takes a node as an input parameter and then execute a page redirect to mailto:[node:field_email] but it simply doesn't do anything, I don't even get any error message in reports. Another doubt I have is in order to do this with multiple email address VBO should gorup all paramenter in a list and call the rule component only once passing a list of email address, I suspect what VBO does is calling the rule component n times passing eache address on every time. So I should find a different way. Any suggestion?
    – oppure
    Commented May 2, 2015 at 14:07

1 Answer 1

0

try integrating the Views Send Module, the instructions specifically mention VBO:

Views Send enables you to send mass mailing from a View.



Since you aren't able to install new modules, it could be done this way:

  • Create the view as a table of fields, include the email address as EMAIL PLAIN TEXT

  • add the VBO field, Save Content (you can choose anything you want, but this seems the least offensive)

  • add some css:

    #views-form-email-test-page #edit-select {   display:none; }
    

    This will hide the VBO button since we are overriding its functionality manually

  • add a header, Global Text:

    <button type="button" onclick="emailUsers(); return false;">email users</button>
    
  • add a modified version (modified for view and field names) of this JS to your html.tpl.php, or drupal_add_js, or by whatever other means you want:

    function emailUsers()
    {
        var toField = '';
    
        jQuery('#views-form-email-test-page table tbody tr').each(function()
        {
            if(jQuery('.views-field-views-bulk-operations div input', this).is(':checked'))
            {
                toField += jQuery('.views-field-field-address', this).html() + ',';
            }
        });
    
        if(toField.length > 0) window.location.href = "mailto:" + toField;
        else alert('Please select at least one user to email!');
    }
    

This all assumes:

  • the View machine name is name email_test
  • the View is a page
  • the field holding the email address is field_address

EDIT FROM OP:

Thank you very much Geoff, your solution works very well, I've learned a few things and I hope it will be usefull for others in the futures, indeed I was quite surprised not to find anything when I searched befor posting. Since my email field was also a link I've used the following code

tmp = jQuery('.views-field-field-applicant-email', this).html(); tmp2 = jQuery(tmp.replace('mailto:','')); toField += jQuery(tmp2).attr('href') + ',';

instead of

toField += jQuery('.views-field-field-address', this).html() + ',';

not very elegant may be (I'm not a programmer) but it works! for some strange reasons I cannot upvote your answer, sorry.

2
  • Thanks Geoffunfortunately Views Send Module doesn't do what I want to do, this module lets users send mass emails trough the website, I don't want this. I just want the user to select all the rows and the when he execute the VBO rule a new email message is opened locally using it's own email client, same as if he clicked on a milto: link.
    – oppure
    Commented May 2, 2015 at 13:54
  • updated my answer
    – Geoff
    Commented May 2, 2015 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.