Amit Mittal
Amit Mittal

Reputation: 1127

Sending batch emails using SMTP using MailGun

Referring to this documentation:

https://documentation.mailgun.com/user_manual.html#batch-sending

I am able to send emails to multiple recipients using the JSON api.

However, my web application is also using Postal for formatting emails and looks like Postal can use only SMTP for sending emails.

I need to send personalized emails to many recipients in a single SMTP call. The problem is, I am not able to figure out how to specify "Recipient Variables" when using SMTP.

I've tried adding the recipient variables to the SMTP header, but looks like Mailgun is not loving that.

MailMessage mail = new MailMessage("[email protected]", emails);
mail.Subject = "Hello2";
mail.Body = "Testing some Mailgun awesomness";           
mail.Headers.Add("recipient_variables", jsonobjects);

How shall we specify "Recipient Variables" when using SMTP? Any help will be greatly appreciated. Thanks.

Upvotes: 1

Views: 2342

Answers (1)

Amir M
Amir M

Reputation: 550

As per Mailgun's reply for this issue, they are missing the specific header in their documentation.

This is the header: X-Mailgun-Recipient-Variables and your code should look like this:

MailMessage mail = new MailMessage("[email protected]", emails);
mail.Subject = "Hello2";
mail.Body = "Testing some Mailgun awesomness";           
mail.Headers.Add("X-Mailgun-Recipient-Variables", jsonobjects);

Upvotes: 0

Related Questions