Gravity
Search…
Email Notifications
You can send email notifications to your users from anywhere in your application.
Emails use a JSON template for content - no need to wrestle with HTML tables. The JSON is then injected into an email template located in the /emails directory.
1
await mail.send({
2
3
4
template: 'welcome',
5
content: {
6
7
name: 'John',
8
plan: 'startup',
9
price: '$49'
10
11
}
12
});
Copied!
You can also use a custom HTML template by passing the name of the file as a custom value.

Sending Notifications to Yourself

If you wish to send a notification to yourself, you can use the mail utility endpoint:
1
POST /api/utility/mail
2
3
// accepts
4
{
5
name: 'from-name',
6
email: 'from-email-address',
7
message: 'message body'
8
}
Copied!
This will send an email to the address stored in SUPPORT_EMAIL environment variable. You can see an example of this in the /help view.

Using Other Mail Providers

The mailing logic is isolated in model/mail with a raw API call, so if you'd like to use a provider other than Mailgun, you can simply update this API call in one location.
Last modified 6mo ago