Secure Emails
Learn how to send the confirmation emails securely through Google Developer Console.
We'll cover the following...
There are two methods that configure Gmail into Nodemailer and Node.js.
- We can use our email and password directly, like this:
Press + to interact
const transporter = nodemailer.createTransport({service: "Gmail",auth: {user: "<your_email>@gmail.com",pass: "<gmail_password>"}});
This method is less secure and may work if we are developing the application locally on our machine. But if we deploy the application, we’ll most likely be blocked by the Gmail client.
- We can use
OAuth2
client credentials, like this:
Press + to interact
const Transport = nodemailer.createTransport({service: "Gmail",auth: {type: "OAuth2",user: "<your_email>@gmail.com",accessToken: "<your_oauth_access_token>",refreshToken: "<your_oauth_refresh_token>",clientId: "<your_gdc_client_id>",clientSecret: "<your_gdc_client_secret>"},});
We used the OAuth2 method ...