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.
You can also use a custom HTML template by passing the file name as a custom
value.
Sending Notifications to Yourself
If you wish to send a notification to yourself, you can use the mail utility endpoint:
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
Gravity uses nodemailer with the default mail service set to Mailgun.
If you wish to use another mail provider, you can simply install the nodemailer transport package for your chosen service and update the mail.send
method in helper/mail
.
Find and install the transport package from npm
Change the require import on line 7 of helper/mail to import your package
Update the authentication object in line 25 of helper/mail to match your service's requirements
A full list of well-known services is available here.
Using Custom Email Templates
Gravity includes a clean, responsive email template, but you can also add your own templates to cover a wider variety of use cases.
I recommend using htmlemail.io for premium templates. Gravity customers get 20% OFF – you’ll receive a coupon via email after you purchase.
For full instructions on how to implement a custom template, please follow the instructions in this blog post.
If you're migrating from a previous version of Gravity, please run the seeds below to populate the database with the email content.
Notification Preferences
Users can't toggle which email notifications they would like to receive in the notifications section of their account.
These settings are stored in the database notifications table. By default, the following preferences are included for you:
new_signin
plan_updated
card_updated
invite_accepted
If you'd like to add more options you, add them to the notifications
object in config. This way, all new users will automatically have the these preferences added to the database.
Last updated