Home/Email API/Send via Gmail

Python send email via Gmail

Yes, Python can send through Gmail with smtplib and an app password. It's fine for a personal script and wrong for a product. Here is both halves, honestly.

Verified By Kam Low, Co-founder · Updated

The honest how-to

For a personal notification script, Gmail over SMTP works: enable 2FA, generate an app password, connect to smtp.gmail.com:587 with STARTTLS, send. Every tutorial shows it because it does work.

Python · personal scripts onlysmtplib
import smtplib
from email.message import EmailMessage

msg = EmailMessage()
msg["From"], msg["To"], msg["Subject"] = "[email protected]", "[email protected]", "Backup done"
msg.set_content("Finished at 02:00.")

with smtplib.SMTP("smtp.gmail.com", 587) as s:
    s.starttls(); s.login("[email protected]", "app-password"); s.send_message(msg)

Why it breaks as a product

The trap is scale one: the day your script serves users instead of you. App passwords expire and trip security alerts. The daily sending cap is built for a person. Your mail authenticates as gmail.com, not your domain, so you can't build sender reputation. And when Google changes auth policy, your product breaks on their schedule.

Gmail is a mailbox. Production email needs a sending platform behind it: your domain, your reputation, delivery events, and no password that expires mid-quarter.

Put numbers on the cap: a personal Gmail account can send 500 emails a day, a Workspace account 2,000, and if the mail is cold outreach the practical ceiling is 30 to 50 a day per mailbox before flags start. The enforcement side has teeth now too: cross a 0.30 percent spam rate and Gmail, Yahoo, and Microsoft will block you outright.

For Gmail specifically, domain reputation matters far more than IP reputation. IP memory runs about 120 days, and a dedicated IP is only worth having past a million emails a month; below that, send from an authenticated subdomain and let the domain carry the trust. Gmail is most of the game anyway. In our own user base, 78 percent of people live in a Google mailbox.

Full parameters and responses live in the REST API docs and the API reference.

The trap
Gmail app password
abcd efgh ijkl mnop
✕ 500 emails/day cap
✕ breaks when 2FA settings change
✕ a full-inbox credential in your code
The fix
POST /v1/messages
Authorization: Bearer ns_live_…
✓ scoped API key, revoke anytime
✓ 8,000 free sends, no daily cliff
✓ delivery events you can act on

Go deeper

Here is the thing an app password never fixes. The real answer to "how do I send email in Python" is not a cleaner Gmail workaround, it is skipping the workaround. Describe the send to Claude, Cursor, or Codex and our MCP server sends it on the same account, on your own domain, with no app password to generate or rotate.

The platform version of this page is send email with Python: same five lines, your own domain, message IDs back. Outlook shop? Same story, different trap. Gmail is the strictest audience you have, which makes SPF, DKIM and DMARC authentication non negotiable and inbox placement the number to watch.

FAQ

How do I send email via Gmail in Python?

Enable 2FA, create an app password, and use smtplib with smtp.gmail.com port 587 and STARTTLS. Reasonable for personal scripts; wrong for products, because of expiring passwords, daily caps, and no domain reputation.

Why does Gmail block my Python script?

Plain passwords are retired, so scripts need app passwords over 2FA, and unusual sending patterns still trigger security blocks. Products should send through an email API with their own authenticated domain instead.

First send in thirty seconds.

Simple pricing. Unlimited contacts.

Every plan includes full stack emailing: Flows, Newsletter Campaigns and Transactional Email, plus our NitroWheel LLM and all agent integrations (Claude, ChatGPT, Codex, Cursor and others). Pay for what you send, not who you store.

Daily allowances depend on your plan and sender standing. Strong list, domain and delivery evidence can raise standing, including on day one. Trusted receives the full plan allowance; available email credits, safety checks and delivery pacing still apply.

Free
$0
forever
  • Emails 8,000then 500/mo
  • Email types Transactional & Marketing
  • AI actions 20/mo
  • Contacts Free & Unlimited
  • Brands 3
  • Seats 1
  • Recipients / rolling 24h 100–5,000
  • Email validation Prepaid only
Start free
Ultra
$100
per month
  • Emails 125,000/month
  • AI actions 5,000/mo
  • Brands 10
  • Seats 10 · Domains 10
  • Frontier AI Included
  • Dedicated IP Available
  • Recipients / rolling 24h 1,000–625,000
  • Email validation Prepaid only
Get started
Enterprise
$300
per month
  • AI actions Unlimited
  • Unlimited brands & domains Included
  • SSO / SAML Included
  • 99.9% SLA Included
  • Recipients / rolling 24h Contracted
  • Email validation Prepaid only
Get started

Free forever. No credit card required. See full comparison →