Smtp

Gmail SMTP settings: server, ports, app passwords and limits

Short answer

Gmail's SMTP server is smtp.gmail.com. Use port 465 with SSL or port 587 with TLS (STARTTLS), your full Gmail address as the username, and a 16-character app password as the password. App passwords need 2-Step Verification turned on. A personal Gmail account can send about 500 messages a day and Google Workspace accounts 2,000, so Gmail SMTP suits low-volume personal sending, not app email.

Last checked 16 November 2026

To send through Gmail over SMTP, connect to smtp.gmail.com on port 465 (SSL) or port 587 (TLS), log in with your full Gmail address, and use an app password, not your normal password. That works for mail clients, scripts and small sites. For app email at any real volume, Gmail’s daily limits get in the way quickly.

Gmail SMTP settings

Setting Value
SMTP server smtp.gmail.com
Port (SSL) 465
Port (TLS / STARTTLS) 587
Authentication Required
Username Your full address, for example you@gmail.com
Password A 16-character app password
Daily limit, personal Gmail 500 messages
Daily limit, Google Workspace 2,000 messages (500 on trial accounts)

The server, ports and Workspace limit come from Google’s send email from a printer, scanner or app page. The personal limit is from Gmail sending limits.

Create a Gmail app password

Google stopped accepting account passwords from third-party apps. It now says Gmail no longer supports apps or devices that ask you to share your Google username and password. Where an app offers “Sign in with Google,” use that. Where it only has username and password fields, use an app password:

  1. Turn on 2-Step Verification for the Google account. App passwords only work when it is on.
  2. Open your Google Account, search for App passwords, and create one. Give it a name you will recognize, like “Office printer.”
  3. Copy the 16-character code. Use it as the SMTP password, without spaces.

You will not see the App passwords option if your account uses only security keys for 2-Step Verification, is enrolled in Advanced Protection, or is a work or school account whose admin has turned it off.

App passwords bypass 2-Step Verification for that one app, so treat them like a real password. Revoke them when a device is retired.

Gmail SMTP with PHP

Most PHP sites send with PHPMailer. These are the settings that matter:

use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host       = 'smtp.gmail.com';
$mail->SMTPAuth   = true;
$mail->Username   = 'you@gmail.com';
$mail->Password   = getenv('GMAIL_APP_PASSWORD');
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // port 465
$mail->Port       = 465;

$mail->setFrom('you@gmail.com', 'Your Name');
$mail->addAddress('sam@example.com');
$mail->Subject = 'Test from PHP';
$mail->Body    = 'It works.';
$mail->send();

For port 587, use PHPMailer::ENCRYPTION_STARTTLS and Port = 587. Mixing them, for example ENCRYPTION_SMTPS with port 587, makes the connection hang and time out.

Keep the From address the same as the Gmail account (or a verified “Send mail as” alias). Gmail rewrites other From addresses to the account you logged in with.

Gmail SMTP with Python

The same settings work from Python’s standard library, with no extra packages:

import os, smtplib
from email.message import EmailMessage

msg = EmailMessage()
msg["From"] = "you@gmail.com"
msg["To"] = "sam@example.com"
msg["Subject"] = "Test from Python"
msg.set_content("It works.")

with smtplib.SMTP("smtp.gmail.com", 587) as s:
    s.starttls()  # upgrade to TLS before logging in
    s.login("you@gmail.com", os.environ["GMAIL_APP_PASSWORD"])
    s.send_message(msg)

For port 465, use smtplib.SMTP_SSL("smtp.gmail.com", 465) and drop the starttls() call.

Gmail SMTP limits

Google publishes these limits:

  • Personal Gmail: 500 messages a day, and no more than 500 recipients on one message.
  • Google Workspace: 2,000 messages a day per user, 500 on trial accounts, and 100 recipients per message when sending over SMTP.
  • What happens when you hit it: sending stops for up to 24 hours, though you can still receive mail. Limits are measured over a rolling 24 hours, not a calendar day.

Those numbers are generous for a person and tight for software. A sign-up flow, a batch of receipts or a password-reset spike can use a day’s allowance in minutes, and when that happens the account owner’s own email stops too.

Common Gmail SMTP errors

Error Meaning Fix
535 5.7.8 username and password not accepted Wrong password type Use an app password, check for typos and spaces
530 5.7.0 must issue a STARTTLS command first Connected on 587 without TLS Enable STARTTLS, or switch to 465 with SSL
Connection timed out Port blocked, or SSL/port mismatch Try the other port; pair 465 with SSL, 587 with TLS
“You have reached a limit for sending mail” Daily quota used Wait up to 24 hours, or move app email elsewhere

Google’s full list is on its SMTP errors and codes page, and our SMTP error codes guide explains the structure of every code.

Gmail SMTP vs the Google Workspace relay

If you have Google Workspace, an admin can enable smtp-relay.gmail.com. It authenticates by IP address or login, can send from any address in your domain, and allows up to 10,000 recipients per user per day. It is the better option for office printers and on-premises servers. The Google Workspace SMTP relay guide walks through the setup.

When to use a transactional relay instead

Use Gmail SMTP for your own mail client and small, personal jobs. Use a transactional email service when:

  • The email is part of your product: confirmations, resets, receipts, alerts.
  • You need more than a few hundred messages a day.
  • You want to know which messages bounced or were marked as spam.
  • You want mail to come from your own domain with SPF, DKIM and DMARC passing.

Mailcandor’s SMTP relay takes the same PHPMailer code with four changes: Host = 'smtp.mailcandor.com', Username = 'mailcandor', Password set to an API key, and your own verified domain in setFrom. Ports 465 and 587 work the same way. The free Starter plan includes 3,000 emails a month (100 a day); pricing has the rest.

Questions

What is the SMTP server name for Gmail?

smtp.gmail.com. Google Workspace also offers smtp-relay.gmail.com, an SMTP relay for whole organizations that an admin must turn on first.

What port does Gmail SMTP use?

Port 465 for SSL (implicit TLS) or port 587 for TLS (STARTTLS). Both need authentication. Port 25 is not used for authenticated Gmail sending.

Why does Gmail reject my password over SMTP?

Gmail no longer accepts your normal account password from third-party apps. Turn on 2-Step Verification, create an app password, and use that 16-character code instead.

How many emails can I send through Gmail SMTP?

Google lists 500 messages per day for a personal account and 2,000 per day for a paid Google Workspace user (500 on trial accounts). Hitting the limit blocks sending for up to 24 hours.

Can I use Gmail SMTP for my website or app?

For a low-traffic contact form, yes. For sign-ups, password resets and receipts, no: the daily cap is low, mail comes from a personal mailbox, and you get no bounce or delivery events.

Related

Send with someone on your side.

Unlimited domains on every plan, a person before any block, and 3,000 emails a month free. Tell us what you send and we set you up within one business day.