Setup Email

Send Emails from your Dapp.

Setup email service in Dapp

Moralis can send emails on your behalf. We can achieve this by integrating SendGrid into the Dapp.
You would need an email service to do the following:
  1. 1.
    Send Welcome emails upon user sign up.
  2. 2.
    Send password reset emails upon user password resetting
  3. 3.
    Send verification emails for new users

1. Configure Email details

Click the "View Details" button on your server instance, then the "Email Configuration" tab. You'll need to sign up for a SendGrid account and provide the following:
  • API Key
  • From Email: This will appear as the "from" address on emails received by users (must be authorized by SendGrid as a single sender or domain).
  • Sendgrid Verification Email Template ID: The template to use for the verification email.
  • Sendgrid Password Reset Template ID: The template to use for the password reset email.
Moralis email configuration

2. Apply Email Template

To enable sending a verification email, or a password reset link, some additional setup is required. Both of these operations require a SendGrid Dynamic Template.
Press the "Create a Dynamic Template" button.
Design the look of the email. Your template must include a {{ link }} tag. When done press "Save".
After saving, it will look something like this. Copy the "Template ID" you see here into your Moralis Server Email Configuration above.
Repeat the steps above to create templates for both email verification and password resets.

3. Create Dynamic Template Data

When creating dynamic templates, the following parameters are sent to the template:
{{ link }} -> (confirmation link or reset password link)
{{ email }} -> the email of the user

4. Send Email

Sending an email must be done on the server-side via cloud code as it requires the MasterKey. This is to help prevent the domain from being blacklisted for spam by bad actors.
// in Cloud Code
Moralis.Cloud.define("sendEmailToUser", function (request) {
to: request.user.get("email"),
subject: "Fundamentals",
html: "Pampamentally it does make sense"


Legacy UI is present in this video, some things might be slightly different
Moralis User Email Verification using Sendrid and ReactJs