
To create an App Password for Gmail SMTP (to securely send emails from your application), follow these steps:
Prerequisites
- Enable 2-Step Verification: App Passwords are only available if 2-Step Verification is enabled on your Google Account.
- Gmail SMTP Settings:
- SMTP Server:
smtp.gmail.com
- Port:
587
(for TLS) or465
(for SSL) - Authentication: Enabled
- Encryption: TLS or SSL
- SMTP Server:
Step-by-Step Instructions
1. Enable 2-Step Verification
- Go to your Google Account Security Settings: https://myaccount.google.com/security
- Under “Signing in to Google”, enable 2-Step Verification:
- Click 2-Step Verification and follow the steps to set it up.
2. Generate an App Password
- Go to the App Passwords page: https://myaccount.google.com/apppasswords
- Log in if prompted.
- Under “Select the app and device you want to generate the app password for”:
- For Select App, choose Mail or select Other (Custom Name) and name it (e.g.,
My SMTP App
). - For Select Device, choose the device or select Other and name it.
- For Select App, choose Mail or select Other (Custom Name) and name it (e.g.,
- Click Generate.
- Copy the generated 16-character App Password. You won’t see it again after leaving the page.
3. Use the App Password in Your Application
- Use this App Password as the SMTP password in your application instead of your Google Account password.
Example SMTP configuration:
- SMTP Server:
smtp.gmail.com
- Port:
587
(TLS) or465
(SSL) - Username: Your full Gmail address (e.g.,
your-email@gmail.com
) - Password: The 16-character App Password.
4. Test Your SMTP Connection
Send a test email from your application to ensure everything works correctly.
Notes
- If you’re using Gmail’s SMTP in production, remember to handle sensitive data (like App Passwords) securely using environment variables or secret management tools.
- Google may block SMTP connections if it detects suspicious activity. Make sure your application adheres to Gmail’s usage policies.