Sending emails

Webhook Relay provides a Mailgun package to easily send emails on various events.

Prerequisites

Create a Function

First, head to the Functions page and create a new function called mailgun.

You can use our helper package mailgun that can send emails. To start sending emails, create a new Function and just import ‘mailgun’ package. This function will need an API key and domain:

-- Import Mailgun helper package
local mailgun = require('mailgun')

local domain = cfg:GetValue('domain')
local api_key = cfg:GetValue('api_key')

-- mailgun.initialize('domain', 'api-key', 'region (us/eu)')
err = mailgun.initialize(domain, api_key, 'us')
if err then error(err) end

-- mailgun.send('[email protected]', 'subject', 'body-here', '[email protected]')
err = mailgun.send('[email protected]', 'test subject', 'test body', '[email protected]')
if err then error(err) end

Then, you will need to enter your API key from the API keys page and set the as config variables for your function. You can find more details on how to find your API keys in Mailgun here.

Create a Bucket

Then, in the https://my.webhookrelay.com/buckets click on “create empty bucket” and type webhook-to-mail. Once created, go to the input details and click on “transform” section to select your Function:

selecting image

Receiving webhooks

In your input or bucket details page you should see your public endpoint, use it to receive webhooks.