MailSlurp logo

guides

Gmail SMTP Server Settings: smtp.gmail.com, Ports, Auth, and Testing

Configure Gmail SMTP server settings with smtp.gmail.com, port 465 SSL or 587 TLS, app passwords, Workspace relay choices, and MailSlurp validation.

The Gmail SMTP server is smtp.gmail.com. Use it when an email client, app, script, or device needs to send mail through a Gmail or Google Workspace mailbox with authenticated SMTP.

For most setup searches, the key questions are simple: which server, which port, which encryption mode, and which credential type. For release-critical app email, there is one more question: did the message actually reach the right inbox with the right headers, links, OTP code, or attachment?

Quick Gmail SMTP settings

Setting Typical value What to verify
SMTP server smtp.gmail.com Use this for Gmail SMTP submission, not Workspace relay
SSL port 465 Use when the client expects SSL from the start
TLS port 587 Use when the client expects STARTTLS
Username Full Gmail or Workspace email address Use the complete mailbox address
Password App password or account-approved auth path Normal passwords are often blocked by account security
Authentication Required Confirm the account, app, and organization policy allow the flow
Sender address The authenticated mailbox or allowed alias Sender mismatch can cause rejection or confusing replies

If you only need the field values, start with smtp.gmail.com, port 465 with SSL or port 587 with TLS/STARTTLS, and the full email address as the username. If the workflow affects customers, continue through the testing checklist before release.

Gmail SMTP vs Google Workspace SMTP relay

Use the right Google mail path for the job:

Goal Server Best fit
Send as a Gmail or Workspace mailbox smtp.gmail.com Email clients, scripts, and apps that authenticate as a mailbox
Relay mail through Google Workspace policy smtp-relay.gmail.com Devices, internal services, and servers governed by Workspace relay settings
Send with richer app control Gmail API or another mail API App-native automation, message metadata, and integration workflows

smtp.gmail.com and smtp-relay.gmail.com are not interchangeable. If your organization has configured Workspace SMTP relay, use the relay route and its policy. If the app is sending as an individual Gmail or Workspace mailbox, use the Gmail SMTP server.

For the relay model, read Google Workspace SMTP relay. For the general protocol model, read SMTP server guide.

Which Gmail SMTP port should you use?

Port 465 with SSL

Use port 465 when the client expects an encrypted connection immediately. Many device and mail-client setup screens label this as SSL.

Port 587 with TLS or STARTTLS

Use port 587 when the client starts in plain SMTP and upgrades with STARTTLS before authentication. Many app libraries and modern SMTP clients use this model.

Avoid mixed port and encryption settings

The most common Gmail SMTP mistake is mixing port and encryption assumptions:

  • port 465 with STARTTLS behavior can fail
  • port 587 with implicit SSL behavior can fail
  • disabling encryption is not appropriate for normal Gmail SMTP submission

When debugging, fix the port/encryption pair before changing account credentials.

Gmail SMTP authentication realities

Gmail no longer treats third-party mail clients as a simple username-and-password field in every case. Google recommends safer sign-in flows where available, and app passwords are an exception path for apps or devices that cannot use "Sign in with Google."

Common realities:

  • a normal Google password may not work in SMTP clients
  • app passwords usually require 2-Step Verification
  • app passwords may not be available for some organization, security-key-only, or Advanced Protection accounts
  • Workspace admins can apply different account and SMTP policies
  • old "less secure apps" guidance should not be used as a setup model

If Gmail returns repeated username/password failures, check the account security model and app-password availability before rotating secrets in your app.

Gmail SMTP configuration checklist

Before testing in a client, script, or app:

  1. Confirm the account is a Gmail or Google Workspace mailbox that should send the message.
  2. Use smtp.gmail.com as the SMTP server.
  3. Choose port 465 with SSL or port 587 with TLS/STARTTLS.
  4. Use the full email address as the username.
  5. Confirm whether the account should use Sign in with Google, an app password, or another organization-approved path.
  6. Confirm the visible sender address is the mailbox or an allowed alias.
  7. Send one controlled message to a safe test inbox.
  8. Inspect headers, body, links, OTP codes, and attachments before using live recipients.

Common Gmail SMTP failures

Username and password not accepted

Likely causes:

  • the app needs Sign in with Google rather than stored SMTP credentials
  • the account needs an app password
  • 2-Step Verification or organization policy changes the allowed auth path
  • the username is not the full mailbox address
  • the app password was revoked after a Google password change

Application-specific password required

This usually means Gmail rejected the current credential path and expects an app password for that app or device. Check whether the account can create one and whether the app should instead use a safer Google sign-in flow.

Must issue a STARTTLS command first

This points to a TLS negotiation issue. The client is trying to authenticate or submit before upgrading the connection. Use port 587 with STARTTLS correctly, or use port 465 with SSL if the client is built for implicit encryption.

Email relay denied

This often means the sender is using the wrong Google path. If the app should relay through Workspace policy, use smtp-relay.gmail.com and the configured relay rules. If it should send as a mailbox, use smtp.gmail.com with mailbox authentication.

Message accepted but the workflow still fails

SMTP acceptance is not the same as product success. The email can still land in spam, carry the wrong sender identity, miss an OTP code, use a broken link, or fail a parser downstream.

Gmail SMTP testing workflow with MailSlurp

Use a two-layer test: SMTP transport first, then inbox outcome.

  1. Check host, port, TLS, and authentication behavior with SMTP tester.
  2. Trigger the actual app or device workflow.
  3. Send the resulting message into Email Sandbox instead of a real user mailbox.
  4. Inspect the received headers with Email header analyzer.
  5. Check sender authentication with SPF checker, DKIM checker, and DMARC checker when the sending domain matters.
  6. Assert subject, body, links, OTP codes, invoices, and attachments with Email integration testing.
  7. Run email deliverability testing if Gmail SMTP is part of a sender or domain change.

That workflow turns Gmail SMTP setup from a manual mail-client check into repeatable release evidence.

Gmail SMTP vs Gmail API

Gmail SMTP is useful when:

  • a legacy client or framework already expects SMTP
  • the workflow is mailbox-oriented
  • simple SMTP compatibility matters more than structured app events

Gmail API is often better when:

  • your app needs richer message operations
  • you want OAuth-first integration behavior
  • mailbox automation or message retrieval is part of the workflow

Relevant pages:

When Gmail SMTP needs a broader workflow

Gmail SMTP can work for mailbox-oriented sending and basic client compatibility. Product teams usually add more around it when they need:

  • signup, password reset, OTP, billing, or notification checks
  • headers and sender-authentication evidence
  • repeatable tests across staging and production-like environments
  • safe inboxes that do not send test traffic to real users
  • deliverability and spam-risk checks after sender changes

If the goal is application mail, pair Gmail SMTP with MailSlurp inbox validation so the workflow is safe to ship.

Use MailSlurp for Gmail SMTP testing

MailSlurp helps teams validate Gmail SMTP behavior with SMTP tester, inspect auth and route details with Email header analyzer, and run broader workflow checks in Email Sandbox. Create a free account at app.mailslurp.com if you need Gmail-related send paths tested before release.

FAQ

What is the Gmail SMTP server?

Use smtp.gmail.com for authenticated Gmail SMTP submission.

What port does Gmail SMTP use?

Use port 465 with SSL or port 587 with TLS/STARTTLS.

Does Gmail SMTP need an app password?

Often yes for apps or devices that cannot use Sign in with Google, especially when 2-Step Verification is enabled. App-password availability depends on the account and organization policy.

Is Gmail SMTP the same as Google Workspace SMTP relay?

No. Gmail SMTP uses smtp.gmail.com for mailbox-authenticated sending. Google Workspace SMTP relay uses smtp-relay.gmail.com and Workspace relay policy.

Why does Gmail SMTP say username and password are not accepted?

Common causes include missing app-password setup, an unsupported auth method, organization policy, a revoked app password, or a username that is not the full email address.

Should teams use Gmail SMTP for production product mail?

They can for the right mailbox-oriented workload, but release-critical workflows should also verify inbox receipt, headers, links, OTP codes, attachments, and deliverability signals before customers depend on them.

Final take

Gmail SMTP settings are simple at the field level: smtp.gmail.com, port 465 with SSL or 587 with TLS/STARTTLS, full email address, and an account-approved auth path. The safer production workflow is to test the SMTP connection, capture the resulting message in MailSlurp, and assert the real inbox outcome before release.