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 George Hartley, Co-founder · Updated July 20, 2026

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.

One Gmail fact most people get backwards while we're here: SendGrid and Mailchimp ran a study on the promotions tab, and promotional email in the tab actually got opened more. Fear of the tab drives a lot of bad engineering. Deliverability to the right tab beats hacks aimed at the wrong one.

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

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.

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.

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

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