Tips & tricks: Scheduling email delivery

It’s always fun chatting with customers about what they like about Mailgun (and what they’d like to see improved ).

It’s always fun chatting with customers about what they like about Mailgun (and what they’d like to see improved ). We spoke to a customer recently who LOVED that they could schedule delivery of their messages at a specific time in the future. Who knew that this little feature would mean so much to some customers. Today’s blog is about how it works, in case it’s not already part of your workflow.

Scheduling email delivery at a particular time

Some emails needs to be delivered as quickly as possible: error reports, password resets, and welcome emails, for example. Others, however, need to arrive at a particular time to be most effective. For instance, a local restaurant might want to send their daily lunch specials everday at 11 am, so people get it right when their stomachs are starting to growl, but before they’ve chosen a restaurant. The same email received at 4pm is a lot less useful!

Here are some other times that scheduling messages makes sense:

  • You want your emails delivered to recipients worldwide at a specific time in their local time zone

  • You want to send an upgrade offer 48 hours after a customer signups for a free trial

  • You’re leaving on vacation but still want your monthly release notes delivered to your users while you are relaxing on a beach

Mailgun makes this easy with the o:deliverytime parameter which is available when you send email through our API or SMTP.

Sample code to schedule message delivery

o:deliverytime is simply a parameter that you specify when sending Mailgun your message. It is set just like to:, from: , subject: and all the other parameters of your email.

Here is what the code could look like to send a single email:


If you want to send different recipients the same email at different times (say at 9am on the East and West Coast), you can using Batch Sending to send up to 1000 recipients in a single API call. Just define the delivery time for each batch when you send it as above. And remember that with Batch Sending, you can use Recipient Variables to personalize each email in the batch with things like First Name, Order Amount, even targeted offers. You can read more about adding Recipient Variables to your emails here.

When scheduling delivery, dates need to be strings encoded according to RFC 2822This 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'

Finally, there are a lot of factors that affect delivery time including the email content itself which influences how likely ESPs like Gmail and Yahoo are to flag it as spam and delay or prevent delivery. 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. In addition to using o:deliverytime, following our Email Best Practices guide is the best way to make sure your emails get delivered in a timely manner.

Happy emailing, The Mailgunners

Sign Up

It's easy to get started. And it's free.

See what you can accomplish with the world’s best email delivery platform.

Related readings

Troubleshooting email soft bounces

It’s easy to focus on the positive metrics, like conversion rate and click-through, to elevate your email campaigns. But what about the negative metrics that are just as...

Read more

Tips & tricks: Avoiding Gmail spam filtering when using Ruby on Rails Action Mailer

It has become clear from our support logs that a lot of developers use Action Mailer to send...

Read more

White labeling DNS records for your customers: Tips and tricks

Many of our customers run large-scale digital marketing applications on top of Mailgun for their own customers...

Read more

Popular posts

Mailgun iconSee what you can accomplish with the world's best email delivery platform. It's easy to get started.Let's get sending