Send emails using Gmail
Send emails using Gmail
Candymail supports all SMTP email services. Gmail is the easiest to set up since everyone has a Google Account.
Gmail should only be used for testing or debugging purposes. In production, consider using a service like Amazon SES, Sendgrid etc that offers SMTP for better deliverability.

Setup a new account

If you have 2-step authentication for your Google Account turned on:

  1. 1.
    Sign up for an App Password for Gmail here
  2. 2.
    Your user will be your email and password will be the App Password

If you don't have 2-step authentication on your Google Account:

  1. 1.
    Allow access for less secure apps here
  2. 2.
    Your user will be your email and password will be your usual login password

Initialize Candymail

Initialize Candymail config with Gmail STMP. The user is your Gmail email address and the pass is the App Password you just generated.
1
candymail.init(automation.workflows, {
2
mail: {
3
host: 'smtp.gmail.com',
4
port: 465,
5
secure: true,
6
auth: {
7
user: process.env.MAIL_USER,
8
pass: process.env.MAIL_PASSWORD,
9
},
10
tls: {
11
rejectUnauthorized: true,
12
},
13
},
14
hosting: { url: process.env.HOSTING_URL },
15
db: { reset: true },
16
debug: { trace: true },
17
})
Copied!

Add Env Vars

Create a .env:
2
MAIL_PASSWORD=password
4
HOSTING_URL=http://localhost:3000
Copied!