Sending Emails

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


  • Mailgun account (provides generous tier)

Webhook Relay provides a helper package mailgun that can send emails. To start sending emails, create a new Function and just import ‘mailgun’ package. This function will need 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('', 'subject', 'body-here', '')
err = mailgun.send('', 'test subject', 'test body', '')
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.

Last updated