Gmail SMTP with app passwords
We can use a regular Gmail account for sending a limited number of SMTP emails daily. This is sufficient for small apps or testing.
This can be setup to use a separate, generated app password instead of your regular email password, which offers better security as the regular email password is not revealed and a user cannot login to the email account using the app password.
Note that while this usually works in local testing, sometimes it may not. In such case you may need to test from an actual server.
- In Gmail click on the Google button then Manage your Google Account.
- Click on Security in the left nav.
- Under How you sign in to Google click on 2-Step Verification. You will need to enable 2-Step Verification to continue.
- Once enabled scroll to the end of this page to the App passwords section.
- Click on App passwords, enter a name for the app and create a new app password.
- Copy the generated app password. Use this in your SMTP settings as the SMTP password.
SMTP_HOST="smtp.gmail.com"
SMTP_PORT=587
SMTP_USER="dogesh@gmail.com"
SMTP_PASS="nqlxgwmtcaosgiyp"