
Learn how to send emails securely using Gmail SMTP with App Passwords. This guide covers enabling 2FA, generating app passwords, and SMTP setup.
If you're trying to send emails through your web application using Gmail SMTP, you're on the right path. Gmail provides a secure and reliable SMTP service, but due to Google’s strict security standards, you'll need to use App Passwords—especially when using a Gmail account created via Google Workspace (formerly G Suite) with 2-Step Verification enabled.
In this blog, we’ll walk you through the entire setup process for using Gmail SMTP to send emails securely.
Before you can generate an App Password, you need to enable 2-Step Verification on your Google account.
Log in to your Gmail account.
Go to Manage your Google Account.
Navigate to Security.
Under the Signing in to Google section, find 2-Step Verification and turn it ON.
Follow the prompts to complete setup using your mobile device.
Now that 2-Step Verification is enabled, you can generate an App Password specifically for your application.
While logged into your Gmail, go to Google Account.
Click on Security.
In the search bar at the top, type App passwords and click the result.
You’ll be prompted to log in again.
Under Select App, choose Mail.
Under Select Device, choose Other and name it (e.g., "My Web App").
Click Generate.
📌 Note the 16-character password displayed. This is your App Password and will be used instead of your normal Gmail password in the SMTP configuration.
Use the following SMTP settings in your application or email client:
SMTP Host: smtp.gmail.com
Port:
587
(TLS)
465
(SSL)
Encryption: TLS or SSL (as per your port)
Authentication: Yes
Username: Your full Gmail address (e.g., yourname@gmail.com
)
Password: The App Password you generated
App Password Not Working?
Double-check that 2-Step Verification is enabled.
Ensure you copied the App Password correctly (no spaces).
SMTP Connect() Failed?
Check firewall and internet restrictions.
Ensure port 587
or 465
is open.
Using Gmail’s SMTP service with App Passwords adds an essential layer of security and reliability to your email-sending functionality. Whether you're building a contact form, a notification system, or a transactional email service, this method ensures your emails are sent securely and comply with Google’s standards.
(2) (0)
No comments