Cold email infrastructure starting at $1/mailbox. Volume discounts down to $0.55.Calculate your cost
Back to Blog
7 min readMo Tahboub

Gmail SMTP Settings: Complete Configuration Guide

Gmail SMTP server settings for WordPress, Python, Node.js, PHP, and automation tools. Step-by-step setup with App Passwords and troubleshooting.

GmailSMTPEmail SetupDevelopment

Gmail SMTP Settings (Copy-Paste Ready)

SMTP Server: smtp.gmail.com
Port: 587 (recommended) or 465
Encryption: STARTTLS (port 587) or SSL (port 465)
Username: your-email@gmail.com
Password: App Password (16 characters)
Authentication: Required

For Google Workspace accounts: Same settings, just use your custom domain email (you@yourcompany.com).

When You Need Gmail SMTP

You need these settings when configuring:

  • WordPress contact forms or plugins (WP Mail SMTP, FluentSMTP)
  • Web applications that send email (Node.js, Python, PHP)
  • CRM platforms (custom SMTP configuration)
  • Automation tools (n8n, Zapier, Make — custom email sending)
  • Desktop email clients (Outlook, Thunderbird)
  • E-commerce platforms (WooCommerce, custom setups)
  • Monitoring/alerting systems
  • IoT devices that send notifications

Step 1: Enable 2-Factor Authentication

Gmail requires 2FA before you can generate App Passwords.

  1. Go to myaccount.google.com/security
  2. Under "How you sign in to Google," find 2-Step Verification
  3. Click and follow the setup (phone number or authenticator app)
  4. Once enabled, proceed to Step 2

Step 2: Generate an App Password

Regular Gmail passwords don't work for SMTP. You need an App Password.

  1. Go to myaccount.google.com/apppasswords
  2. Sign in if prompted
  3. Under "Select app," choose Mail (or "Other" and name it)
  4. Under "Select device," choose your device or Other
  5. Click Generate
  6. Copy the 16-character password (format: xxxx xxxx xxxx xxxx)
  7. Use this password in your SMTP configuration — spaces optional

Save this password somewhere secure. Google only shows it once.

Step 3: Configure Your Application

WordPress (WP Mail SMTP Plugin)

  1. Install and activate WP Mail SMTP
  2. Go to WP Mail SMTP → Settings
  3. Choose Other SMTP as the mailer
  4. Configure:
    • SMTP Host: smtp.gmail.com
    • Encryption: TLS
    • SMTP Port: 587
    • Authentication: ON
    • Username: your Gmail address
    • Password: App Password
  5. Save and send a test email

Python (smtplib)

import smtplib
from email.mime.text import MIMEText

sender = "you@gmail.com"
app_password = "xxxx xxxx xxxx xxxx"
recipient = "them@example.com"

msg = MIMEText("Hello from Python!")
msg["Subject"] = "Test Email"
msg["From"] = sender
msg["To"] = recipient

with smtplib.SMTP("smtp.gmail.com", 587) as server:
    server.starttls()
    server.login(sender, app_password)
    server.sendmail(sender, recipient, msg.as_string())

print("Email sent!")

Node.js (Nodemailer)

const nodemailer = require('nodemailer');

const transporter = nodemailer.createTransport({
  host: 'smtp.gmail.com',
  port: 587,
  secure: false,
  auth: {
    user: 'you@gmail.com',
    pass: 'xxxx xxxx xxxx xxxx'
  }
});

transporter.sendMail({
  from: 'you@gmail.com',
  to: 'them@example.com',
  subject: 'Test Email',
  text: 'Hello from Node.js!'
});

PHP (PHPMailer)

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 = 'xxxx xxxx xxxx xxxx';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;

$mail->setFrom('you@gmail.com');
$mail->addAddress('them@example.com');
$mail->Subject = 'Test Email';
$mail->Body = 'Hello from PHP!';
$mail->send();

n8n (Automation)

  1. In n8n, add a Send Email node
  2. Select credential type: SMTP
  3. Configure:
    • Host: smtp.gmail.com
    • Port: 587
    • SSL/TLS: STARTTLS
    • User: your Gmail address
    • Password: App Password
  4. Save and test

Gmail SMTP Sending Limits

Account TypeDaily LimitPer Minute
Free Gmail (@gmail.com)500 emails/day~20/minute
Google Workspace2,000 emails/day~30/minute
Google Workspace (first 24h)500 (new accounts)Ramps up

Important: These limits include ALL emails — not just SMTP. Emails sent from the Gmail web interface count toward the same limit.

If you hit the limit: Gmail blocks sending for up to 24 hours. You'll see an error like "You have reached a limit for sending mail."

Port 587 vs Port 465

PortEncryptionProtocolStatus
587STARTTLSStarts unencrypted, upgrades to TLS✅ Recommended
465SSL/TLSEncrypted from start✅ Also works
25None/STARTTLSServer-to-server only❌ Blocked by most ISPs

Use port 587 for most configurations. Port 465 if your application doesn't support STARTTLS.

Troubleshooting

"Authentication failed" / "Username and password not accepted"

Fixes:

  1. Use an App Password, not your regular Gmail password
  2. Make sure 2FA is enabled (required for App Passwords)
  3. Double-check the username is your full email address
  4. Regenerate the App Password and try again
  5. Check for extra spaces when pasting the App Password

"Connection timed out" / "Could not connect"

Fixes:

  1. Verify server: smtp.gmail.com (not smtp.google.com)
  2. Verify port: 587 (TLS) or 465 (SSL)
  3. Make sure your firewall/hosting allows outbound connections on port 587
  4. Some shared hosting providers block port 587 — contact your host
  5. Try port 465 with SSL if 587 doesn't work

"Daily sending limit exceeded"

Fixes:

  1. Wait 24 hours — Gmail resets the counter
  2. Check if other apps/services are using the same account
  3. Upgrade to Google Workspace for 2,000/day limit
  4. For higher volume, use dedicated email infrastructure

"Less secure app access" / "Sign-in attempt blocked"

This error is from Google's old security model. The fix:

  1. Enable 2-Factor Authentication
  2. Generate an App Password
  3. Use the App Password instead of your regular password
  4. "Less secure apps" setting is no longer needed with App Passwords

Emails going to spam

Gmail SMTP deliverability depends on:

  • Your sending patterns (sudden spikes trigger filters)
  • Email content (spammy words, lots of links)
  • Recipient engagement (if people mark you as spam)
  • Whether you've set up SPF/DKIM for your domain

For Google Workspace with custom domains, configure:

  • SPF record pointing to Google
  • DKIM signing enabled in Admin Console
  • DMARC policy set

Gmail SMTP vs Dedicated Email Infrastructure

Gmail SMTP works for:

  • ✅ Transactional emails (confirmations, receipts)
  • ✅ Contact form notifications
  • ✅ Low-volume automated emails (under 500/day)
  • ✅ Personal or small team communication

Gmail SMTP does NOT work for:

  • ❌ Cold email outreach at scale
  • ❌ High-volume email campaigns
  • ❌ Outbound where deliverability is critical
  • ❌ Sending more than 2,000 emails/day

For cold email and outbound at scale, ColdRelay provides purpose-built infrastructure:

  • No daily sending limits like Gmail
  • $1 per mailbox — add capacity as needed
  • SPF, DKIM, DMARC pre-configured per mailbox
  • Designed for cold email — optimized deliverability for outbound
  • Multiple mailboxes for rotation and scaling

Use Gmail SMTP for your app's transactional email. Use ColdRelay for your outreach.

FAQ

Can I use Gmail SMTP for free?

Yes — Gmail SMTP is free for all Gmail accounts. The only cost is if you use Google Workspace ($6-18/user/month) for a custom domain.

Is Gmail SMTP secure?

Yes, when using TLS (port 587) or SSL (port 465). All data is encrypted in transit. Never use unencrypted SMTP (port 25) with Gmail credentials.

Can I send from a different "From" address using Gmail SMTP?

Yes — in Gmail settings, you can add "Send mail as" aliases. Gmail SMTP will then allow you to send from those addresses. The receiving server may still show "via gmail.com" header.

Does Gmail SMTP work with custom domains (Google Workspace)?

Yes. Same settings (smtp.gmail.com, port 587), just use your custom domain email as the username.

Why is my App Password not working?

Common causes: extra spaces when pasting, 2FA not fully enabled, using the wrong Google account, or the App Password was revoked. Regenerate a new one.


Gmail SMTP handles the basics. ColdRelay handles the scale. Cold email infrastructure at $1/mailbox — no daily limits, purpose-built deliverability.