Picture this: You’re on vacation, but your email marketers don’t want to miss the optimal window to send an email to your subscribers. They need you to get the email out, but between the margaritas, you really don’t want to be thinking about work.
At Mailgun, we’ve got you covered. Schedule your email campaigns with ease using our Email API so your marketing team stays happy with optimized send times. Below, we’ll look at the benefits of scheduling email deliveries, then we’ll go through a tutorial on how to schedule email messages with Mailgun.
While some emails need to be delivered as quickly as possible, like error reports, password resets, and welcome emails, other emails should be sent at a scheduled time to be most effective.
For instance, a tech hardware website might want to send their daily deals every day at 8:45 AM, so their customers receive it right when they check their emails before settling into the work grind. The same email is a lot less useful at 5 PM when their subscribers can’t wait to get off of work.
The benefits of scheduling send times are:
Similar to email automation, scheduled email deliveries are just the next step to enable us to do more in less time – and that works for us.
Let’s see how Mailgun’s Email API squares up to the task if you’re looking to optimize your scheduled email deliveries. In the following tutorial, we’ll go over how to use the messages endpoint of our Mailgun API to schedule an email blast.
You can adjust to code below with your own details, like your API key and domain name, to send a POST request to the Mailgun API to compose a new email and schedule it for later:
curl -s --user 'api:YOUR_API_KEY'
https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages
-F from='Sender Bob <sbob@YOUR_DOMAIN_NAME>'
-F to='alice@example.com'
-F subject='Hello'
-F text='Testing some Mailgun awesomeness!'
--form-string html='<html>HTML version of the body</html>'
-F o:deliverytime='Fri, 14 Oct 2011 23:10:10 -0000'
The above request includes the following parameters:
to
(required): Supply one or more email recipient(s) in the to
parameter. This parameter can take a list of emails separated by commas. Check out our documentation on batching and mailing lists for ways to send large email blasts to many recipients.from
(required): The from
parameter indicates the sender of your email.subject
: Supply your email’s subject line in the subject
parameter.text
: The text
parameter is a plaintext message you can include in the body of your email.html
: The html
parameter allows you to insert HTML into the body of your email by pasting it between the tags. Remember, you can also upload your HTML email template using our Templates API and use the template
parameter to call it in this request.o:deliverytime
(required): The o:deliverytime
parameter is probably the most important part of this API request. This parameter is available when you send emails through our API or SMTP. Use this parameter to specify when you’d like Mailgun to send your message.When scheduling delivery, dates need to be strings encoded according to RFC 2822. This format is native to JavaScript and is also supported by most programming languages out of the box:
'Thu, 13 Oct 2011 18:02:00 GMT'
In the tutorial above, we mentioned that it’s possible to include a list of emails in the to parameter. Of course, this gets unwieldy when you’re trying to send an email marketing campaign to 1000 recipients spread across different time zones.
That’s why we created the Time Zone Optimization functionality. Mailgun’s Timezone Optimization feature allows senders to schedule messages to be delivered in a recipient’s local timezone.
Mailgun will make every effort to deliver your emails as close to your specified time as possible, but can’t guarantee delivery at a specific time. After all, there are a lot of factors that affect delivery time, including the email content itself. These factors influence how likely email clients like Gmail and Yahoo are to flag it as spam and delay or prevent delivery.
And that’s it! Sip that margarita and keep your email marketers happy as your emails land in your subscribers’ inboxes.
In addition to using o:deliverytime
, check out our Email Best Practices to make sure your emails get delivered on time. Or, if you’re working with Node.JS, take a peek at our tutorial for scheduling email deliveries. As always, make sure to keep email accessibility in mind.
Don’t hesitate to reach out if you have any questions about how Mailgun can support you. We’re here to help you send all your emails whenever you need them.