How to Find Your Email Password for Sending Emails

Getting Email and Password for Gmail Services

To use Gmail as your email service for Nodemailer, you need a Gmail account and an App Password. Google restricts the usage of regular account passwords for third-party apps for security reasons. Follow these steps to generate an App Password for your Gmail account.


Step-by-Step Guide to Generate an App Password

1. Enable 2-Step Verification

First, you need to enable 2-Step Verification for your Google account:

  1. Go to your Google Account: myaccount.google.com.

  2. Click on "Security" in the left-hand menu.

  3. Under "Signing in to Google," find "2-Step Verification" and click on it.

  4. Follow the on-screen instructions to set up 2-Step Verification.

2. Generate an App Password

After enabling 2-Step Verification, you can generate an App Password:

  1. Go back to your Google Account: myaccount.google.com.

  2. Click on "Security" in the left-hand menu.

  3. Under "Signing in to Google," find "App passwords" and click on it.

  4. You might need to sign in again.

  5. Under "Select the app and device you want to generate the app password for," select "Mail" and "Other" (name it "Nodemailer" or something similar).

  6. Click "Generate."

  7. Google will provide a 16-character App Password. Copy this password.


Using the App Password with Nodemailer

Replace your actual Gmail password with this App Password in your environment variables. Here’s how to update your .env file:

envCopy codePORTAL_EMAIL=your-email@gmail.com
PORTAL_PASSWORD=your-app-password

Ensure that you keep this App Password secure and do not hard-code it into your application.

Instructor: Muhammad Sufiyan

Linkedin: linkedin.com/in/innosufiyan