Reputation: 215
I am new bie for send grid. I have checked this url for two emails "https://sendgrid.com/api/mail.send.js..." and got the mail successfully in both emails.
The mail received by the users from the above URL have both email address in "TO" field like For ex. User Test To: [email protected];[email protected]. and For User test2 To: [email protected];[email protected].
As per my requirement i want to send mail for multiple user and the each recipents have only his email address not the others. For ex. User Test To: [email protected] and For User test2 To: [email protected].
Can this scenario is possible with send grid.
Thanks
Upvotes: 1
Views: 7592
Reputation: 6047
possible on Sendgrid. You can use the normal bcc on sendgrid via personalization, but we dont like it because the To:
is always required. So my solution is sendgrid transactional email. This will send 1 email to multiple users (using sendgrid / php / laravel ):
$email = new \SendGrid\Mail\Mail();
$email->setFrom("[email protected]", "Sender Name");
$email->setSubject("Your subject");
$email->addTo(
"[email protected]",
"User One",
[],
0
);
$email->addTo(
"[email protected]",
"User Two",
[],
1
);
$email->addTo(
"[email protected]",
"User Three",
[],
2
);
$email->addContent("text/plain", "your body");
$email->addContent("text/html", "<strong>your body</body>");
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
try {
$response = $sendgrid->send($email);
return response()->json($response, 200);
} catch (Exception $e) {
return response()->json($e->getMessage(), 400);
}
Upvotes: 0
Reputation: 97
Send email on Azure Mobile Service /NodeJS
var sendgrid = new SendGrid('KEY');
sendgrid.send({
to: toEMail, // ["[email protected]", "[email protected]",...]
from: fromEMail,
subject: subject,
text: body
}, function (success, message) {
console.log("send mail: " + subject);
// If the email failed to send, log it as an error so we can investigate
if (!success) {
console.error(message);
}
});
Upvotes: 0
Reputation: 3986
You can send the same email to multiple recipients by using the SendGrid SMTP API's to
parameter.
To do this you'll set an X-SMTPAPI:
header in your message, this header will include the JSON to communicate with SendGrid's SMTP API. The header will look as such:
X-SMTPAPI: { "to": [ "[email protected]", "[email protected]" ] }
Each recipient will receive a unique email, addressed only to them.
Be aware: you'll still need to set a To:
header for the message to send, however you can set this to yourself or one of the recipients (and then exclude them from the JSON list).
Upvotes: 6
Reputation: 77
Send grid being a standard SMTP server will respond as if you are sending email from gmail, yahoo or outlook.
The scenario is not possible that I am aware of. I have only incorporated it into 2 applications, so I am certain there are better experts.
As an alternative you could test using the blind copy, The problem with that is would need a main address in the To field, which may not fill your requirement.
Upvotes: 0