- Quick tips
How to Improve Holiday Supply Chain Communication with Email
Good news everyone!
Mailgunners been in the lab, keyboards in hands, trying to get some code off - and now Mailgun 2.0 is out. Today we are starting a short series of blog posts that tell you about all the exciting features we have built. If you can’t wait, you can always read our docs about the all the goodies in the new release.
We want to begin by saying: “NO MORE MIME!”
That’s right, you no longer need to deal with MIME email message format to submit feature-rich messages HTML bodies, attachments and so on.
The bitter truth is that not all programming languages are blessed with easy to use, well-documented and bug-free MIME libraries. Yet, nearly everyone knows how to make an HTTP POST request these days, which is ironic because underlying data formats are the same.
Another trend we noticed is that many programmers are not email experts…and why should they be? For example, we have been asked numerous times how to implement “Bcc” functionality or how to attach a file to a message.
Aiming to be the best email platform out there, we have decided to take a deeper look at how email messages are being created and sent. We are done asking our developers to read Wikipedia articles on multi-part emails and wrestle with MIME libraries of questionable quality.
Mailgun new message sending API is simple. Post parameters via HTTP to us and we build MIME and send your message out. What parameters? The ones you would expect: “From”, “To”, “Cc”, “Bcc”, “Subject”, “HTML body”, “attachment file”. You get the idea - same stuff Gmail GUI offers.
This means you can send non-trivial emails using good old curl…or even browser-based JavaScript! Of course, you old-schoolers are welcome to still use your own MIME with SMTP, or submit MIME via HTTP: we are fully backwards compatible.
Enough talking, lets look at some code. Most programming languages have built-in support for making HTTP requests, but for higher-level joy we recommend restclient for Ruby or requests for Python.
To get started, let’s send a simple text message:
curl --user api:key https://api.mailgun.net/v2/farfaraway.uk/messages
-F from='Shrek <cuteogre@farfaraway.uk>'
-F to='Fiona <princess@farfaraway.uk>'
-F subject='Status update'
-F text='The cat is off the hook'
How about a multipart message with text and HTML parts with multiple recipients and a few attachments, which also has a BCC recipient? Easy:
curl --user api:key https://api.mailgun.net/v2/farfaraway.uk/messages
-F from='Shrek <cuteogre@farfaraway.uk>'
-F to='Fiona <princess@farfaraway.uk>'
-F bcc='Donkey <donkey@farfaraway.uk>'
-F subject='Status update'
-F text='The cat is off the hook'
-F html='The cat is off the
hook!
'
-F attachment=@kitchen-photo.jpg
Users who wish to set custom MIME headers can still do so without ever touching MIME. If a POST parameter begins with “h:” prefix, Mailgun recognizes it as a custom MIME header. Here’s an example of sending a message with a custom Message-Id header:
curl --user api:key https://api.mailgun.net/v2/farfaraway.uk/messages
-F from='Shrek <cuteogre@farfaraway.uk>'
-F to='Fiona <princess@farfaraway.uk>'
-F subject='Status update'
-F text='The cat is off the hook'
-F h:Message-Id='mycustomid-1231@farfaraway.uk'
There you have it: a clean and simple way to avoid MIME mess. You can see more API tricks in the documentation link below. Some other cool tricks you can include sending in test mode or scheduling for a specific delivery time.
Take a look: https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-api
Peace! — Mailgunners
Learn about our Deliverability Services
Looking to send a high volume of emails? Our email experts can supercharge your email performance. See how we've helped companies like Lyft, Shopify, Github increase their email delivery rates to an average of 97%.
Last updated on August 28, 2020
How to Improve Holiday Supply Chain Communication with Email
What Is a RESTful API, How It Works, Advantages, and Examples
Email’s Not Dead Season 3 Is Finally Here
Continuing Our Commitment: HTTPS Innovation And Optimization
Easier and Faster Implementation with Our Updated SDKs
The Difference Between SMTP and API
When Should You Use An Email API?
Inbox Placement - Delivery Made Simple
Together At Last: Postman Meets Mailgun
Same API, New Tricks: Get Event Notifications Just In Time With Webhooks
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Become an Email Pro With Our Templates API
Google Postmaster Tools: Understanding Sender Reputation
Navigating Your Career as a Woman in Tech
Implementing Dmarc – A Step-by-Step Guide
Email Bounces: What To Do About Them
Announcing InboxReady: The deliverability suite you need to hit the inbox
Black History Month in Tech: 7 Visionaries Who Shaped The Future
How To Create a Successful Triggered Email Program
Designing HTML Email Templates For Transactional Emails
InboxReady x Salesforce: The Key to a Stronger Email Deliverability
Implementing Dmarc – A Step-by-Step Guide
Announcing InboxReady: The deliverability suite you need to hit the inbox
Designing HTML Email Templates For Transactional Emails
Email Security Best Practices: How To Keep Your Email Program Safe
Mailgun’s Active Defense Against Log4j
Email Blasts: The Dos And Many Don’ts Of Mass Email Sending
Email's Best of 2021
5 Ideas For Better Developer-Designer Collaboration
Mailgun Joins Sinch: The Future of Customer Communications Is Here
Always be in the know and grab free email resources!
By sending this form, I agree that Mailgun may contact me and process my data in accordance with its Privacy Policy.