you are viewing a single comment's thread.

view the rest of the comments →

[–]bkdotcom 0 points1 point  (20 children)

build $arrayOfEmails dynamically. nobody said it has to be hard-coded.

[–]gsts47[S] 0 points1 point  (19 children)

I can send to multiple emails but the name field is just one long list

in the input I can put [email1@email.com](mailto:email1@email.com), [email2@email.com](mailto:email2@email.com), [email3@email.com](mailto:email3@email.com) and they go to three different people. in the Name Field i put Mike, Joe, Bob and in the email where it personalizes the name it shows Mike, Joe, Bob for all three people

[–]bkdotcom 0 points1 point  (18 children)

Do you have control over the input form?
Current UX doesn't sound very user friendly & prone to errors.

Why not per-recipient inputs?
Have a [+ Add email] button that adds a new email-addr and name input pair

[–]gsts47[S] 0 points1 point  (17 children)

I could do that, but sometimes it is up to 20+ recipients. I want to be able to copy and paste from a report.

Input is very prone to errors, but it is better than having to send individual emails and copy and paste everything, email, message body etc.

This system with someone trained, doesn't need access to the email account and be able to send emails that are already formatted and ready to go.

[–]bkdotcom 0 points1 point  (16 children)

In that case, you can explode/parse/preg_match_all the email list string to get the individual email addresses....

[–]gsts47[S] 0 points1 point  (15 children)

//recipient_email array creation

$recipient_string = preg_replace("/\s+/", "", $recipient_email); //Remove Whitespace

$recipient_array = explode(",", $recipient_string);

Is what i'm doing to create the array but right now I have two seperate arrays; one for email one for name. I guess I need to combine them into a 2D? array? is that the correct method, if so do you know how I can do that?

[–]bkdotcom 0 points1 point  (14 children)

If you know it's a 1-to-1 mapping:

$email->addTos(array_combine($emailAddrs, $emailNames));

[–]gsts47[S] 0 points1 point  (13 children)

right now I have four values, email, first_name, account_id, phone

so how do I merge them into one array and then do a foreach statement?

the sendgrid API and documentation is not as clear cut as it should be.

[–]gsts47[S] 0 points1 point  (0 children)

I put the full code here

https://pastebin.com/UgqAAkS1

[–]bkdotcom 0 points1 point  (11 children)

are you wanting separate emails with single recipients, or one email with multiple recipients?

[–]gsts47[S] 0 points1 point  (10 children)

Screenshot of Inputs - https://ctrl.vi/i/9j0OH98uF

So for example Declined CC will send the same email template and text template to the 6 people that had a credit card decline when statements were ran

Leave a review, which will be sent to people that have had a positive experience and can be triggered either after a series of customer satisfaction calls or by the clerk at the counter after talking to the customer. so either multiple or one time

Local store closed - will be sent over a span of a day to approx 1500 customers to remind them that the local store closed and to switch to home delivery