Cronhooks Blog

Schedule email with mailgun and cronhooks

July 17, 2019 • ☕️ 2 min read

Introduction

Mailgun is a great service for sending transactional emails via rest api. While cronhooks provides webhooks scheduling service. I was curious that is it possible to use the mailgun api directly in cronhooks to schedule mail with using any backend code or even any middleware. After a couple of experiments, i was able to schedule an email using directly mailgun api as webhook.

Let’s start scheduling

There are couple of things todo before we can make this happen. First of all you’ll need a mailgun account which you can create here. In free account you’ll need to verify recipient email address before you can receive emails and cronhooks account which you can create for free here. After logging in mailgun you’ll receive a domain url which looks like sandbox45dsfdsdsf33434dfdfd.mailgun.org and an api key.

Mailgun api requires a authorization header which uses basic authentication. Below are the details of header and all required params to work for mailgun api in cronhooks.

Create a schedule in cronhooks with below content.

Method: POST

Url: https://api.mailgun.net/v3/yourmailgundomain_url/messages

Content Type: application/x-www-form-urlencoded

Headers:

Authorization: Base64(‘api:your_mailgun_key‘)

Params:

to: rameezraja@cronhooks.io

from: Your Name <yourmailgundomain_url>

subject: Cronhooks via Mailgun

text: Testing some Mailgun awesomeness with cronhooks!

Select any timezone and time. That’s all click ‘Create Schedule’ and you are ready to go. You will shortly recieve an email as per your schedule.

You can try Cronhooks for free. It’s my side gig and I’d love your feedback and suggestions!