Hey everyone, I’m trying to figure out how to send personalized invoice emails using Mailgun’s batch-send feature. I know how to use basic recipient variables like %recipient.FirstName%
, but I’m stuck on how to include a list of ordered items for each recipient.
Here’s what I want to do:
- Send personalized emails to multiple recipients
- Include a list of ordered items for each recipient
- Display item details like name, price, and amount
Is it possible to do something like this in Mailgun?
Dear %recipient.FirstName%,
Your ordered items:
%for item in recipient.OrderedItems%
%item.Name% - %item.Amount% x %item.Price%
%endfor%
Can Mailgun handle this kind of complex template or do I need to generate the email content manually before sending it through Mailgun? I’d appreciate any insights!
hey charlottew, mailgun’s recipient variables are pretty basic. for complex stuff like that, you’ll prob need to generate the content beforehand. i’ve done something similar by creating a html template, filling it with data server-side, then sending that through mailgun. works well but takes more prep work on ur end.
I’ve encountered similar challenges in my email campaigns. Mailgun’s built-in recipient variables work well when the personalization is simple, but when you need to insert detailed, itemized content, they become limiting. In my experience, it is more effective to generate the complete email content on your server. I would create a HTML template and use a templating engine to insert the recipient’s data directly into the email. Once the final HTML is ready, I send the emails via Mailgun’s API. Although this method requires more setup initially, it offers the flexibility needed for complex personalization.
Mailgun’s recipient variables are indeed limited for complex scenarios like yours. A more robust approach would be to pre-generate the email content on your server before sending it through Mailgun. You could create a HTML template with placeholders for the dynamic content, then use a templating engine to populate it with each recipient’s data. This method gives you full control over the layout and content. Once you have the personalized HTML for each recipient, you can use Mailgun’s API to send individual emails or leverage their MIME messages feature for batch sending. It requires more upfront work but offers greater flexibility for complex personalization needs.