简体   繁体   中英

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("foo@sandboxce6d7987d87741098c67b8437378847d.mailgun.org", 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.

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("foo@sandboxce6d7987d87741098c67b8437378847d.mailgun.org", emails);
mail.Subject = "Hello2";
mail.Body = "Testing some Mailgun awesomness";           
mail.Headers.Add("X-Mailgun-Recipient-Variables", jsonobjects);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM