Page 1 of 4

email array to sendgrid

Posted: Fri Mar 21, 2014 11:10 pm
by casey palmer

what is the proper format to send an array in a request parameter.. sorry im new at this but love it so far...


email array to sendgrid

Posted: Fri Mar 21, 2014 11:23 pm
by Illya Stepanov

Hi Casey -

Can you show what exactly you have tried to send?


email array to sendgrid

Posted: Fri Mar 21, 2014 11:33 pm
by casey palmer

trying to send multiple emails in the "to" request field of the sendgrid plugin

from the doc on SendGrid "to[]=a href="mailto:a@mail.com" rel="nofollow"a@mail.com/a&to[]=a href="mailto:b@mail.com" rel="nofollow"b@mail.com/a"

in testing the service I send something like this::

[{"to":"a href="mailto:email1@aol.com" rel="nofollow"email1@aol.com/a"}, {"to":a href="mailto:email2@aol.com" rel="nofollow"email2@aol.com/a}]


email array to sendgrid

Posted: Sat Mar 22, 2014 10:45 pm
by Alena Prykhodko

Hello Casey,

We need additional time to look into this. Sorry for delay. We'll update asap.


email array to sendgrid

Posted: Mon Mar 24, 2014 5:04 am
by Igor

Hi Casey.

Unfortunately there is no available multiple addresses in this plugin by default.

But if you want to do it you can try next steps:

1 open Services-SendGrid_MailSend.

2 Request. Delete "to" parameter.

3 Invoke service only via javascript code:

pre
sendgrid_mailsend.execute({data: {"to[]": ["yourfirstEmail@sss.com", "yoursecondEmail@sss.com"]} });
/pre
It will generate request with multiple to[] parameters. Please check it after in "net" tab of the browser debugger.


email array to sendgrid

Posted: Thu Apr 24, 2014 4:56 am
by Nathan Morin

Igor-

Two questions:

  1. For your #3, instead of having my button's click action be set to "Invoke Service", I would have the click action be "Run Javascript" with the code above?

  2. Is it possible to use this javascript to have variable email addresses?

    Am I able to do something like this?

    var email1 = localStorage.getItem('clientEmail1');
    var email2 = localStorage.getItem('clientEmail2');
    var email3 = localStorage.getItem('clientEmail3');

    sendgrid_mailsend.execute({data: {"to[]": [email1, email2, email3]} });

    Thanks for your help.

    Cheers,

    Nathan


email array to sendgrid

Posted: Thu Apr 24, 2014 5:46 am
by Illya Stepanov

Hello -

  1. Yes, you should set action "Run JavaScript" on click event with above code.
  2. You can use local storage variable to store the email and use the values ​​in the code.

email array to sendgrid

Posted: Thu Apr 24, 2014 6:31 am
by Nathan Morin

Thanks for the fast response. So this is the code I wrote. It will send to the first email address but not the other three. I made an alert to make sure that the local storage variables had values. I checked the spam and junk folders on the other three accounts and nothing came through. But it will come through to the first email. What am I doing wrong?

My code:

var email1 = localStorage.getItem('clientEmail');
var email2 = localStorage.getItem('clientEmailTwo');
var email3 = localStorage.getItem('clientEmailThree');
var email4 = localStorage.getItem('clientEmailFour');

//alert(email2 + " " + email3 + " " + email4);

sendgrid_mailsend.execute({data: {"to[]": [email1, email2, email3, email4]} });


email array to sendgrid

Posted: Thu Apr 24, 2014 9:52 am
by Nathan Morin

Thanks for the fast response. So this is the code I wrote. It will send to the first email address but not the other three. I made an alert to make sure that the local storage variables had values. I checked the spam and junk folders on the other three accounts and nothing came through. But it will come through to the first email. What am I doing wrong?

My code:

var email1 = localStorage.getItem('clientEmail');
var email2 = localStorage.getItem('clientEmailTwo');
var email3 = localStorage.getItem('clientEmailThree');
var email4 = localStorage.getItem('clientEmailFour');

//alert(email2 + " " + email3 + " " + email4);

sendgrid_mailsend.execute({data: {"to[]": [email1, email2, email3, email4]} });


email array to sendgrid

Posted: Thu Apr 24, 2014 4:21 pm
by casey palmer

I have to say I never was able to get this to work for me.. I ended up switching to Mandrill. I still use SendGrid for a backup email. With Mandrill I I was able to send email to multiple recipients and also create an HTML template and then send merge tags to replace the placeholders in the template before sending.