How to create a Gmail app password
- Turn on 2-Step Verification at myaccount.google.com → Security. App passwords are only available with it on.
- Open myaccount.google.com/apppasswords, type a name such as "SMTP" and click Create.
- Copy the 16-character password. Google shows it only once. Use it as the SMTP password, with or without the spaces.
- Delete it from the same page when you no longer need it. Deleting it doesn't affect your normal sign-in.
On a Google Workspace account the admin can turn app passwords off. If the page says app passwords aren't available, ask your admin, or use smtp-relay.gmail.com, which Workspace admins can set up to accept mail by IP address.
Port 587 or 465?
Both work with Gmail. Port 587 starts plain and upgrades with STARTTLS; port 465 is encrypted from the first byte (SSL/TLS). Pick whichever your app supports, but match the security setting to the port: SSL/TLS on 587 or STARTTLS on 465 fails before login. Port 25 also exists on smtp.gmail.com, but most networks and cloud hosts block it. See what SSL email is for the difference.
Common Gmail SMTP errors
- 534 5.7.9 Application-specific password required: use an app password instead of your account password.
- 535 5.7.8 Username and Password not accepted: wrong username or app password. Use the full address and create a fresh app password.
- Connection timed out: the port is blocked on your network, or SSL/TLS is set on port 587. Try 465 with SSL/TLS.
- 550 5.4.5 Daily user sending quota exceeded: you hit Google's daily limit. Sending unlocks within 24 hours.
Sending from a custom domain through Google Workspace? If recipients see "via gappssmtp.com", your domain has no DKIM key. Check your domain.