How to Set Up SMTP: Ports, Authentication, and a Faster Way to Send
What "setting up SMTP" actually means
SMTP is the protocol your application uses to hand an email to a mail server for delivery. Setting it up means giving your app four things so it can log in to that server and send: the host, the port, the encryption type, and a username and password.
That's the whole job. Everything else people search for around this is a variation on those four values for a specific provider.
For most setups it looks like this:
- Host: the address of the outgoing server, e.g.
smtp.gmail.comorsmtp.office365.com - Port:
587for TLS (the modern default) or465for SSL (legacy) - Encryption: STARTTLS on 587, or implicit SSL on 465
- Authentication: your account username and a password or app password
Ports: 587, 465, and the one to avoid
Three ports come up constantly. Only two of them are worth using.
- Port 587 (submission, STARTTLS): the one you want. Your client connects in plaintext and upgrades to TLS before sending credentials. Nearly every provider supports it.
- Port 465 (implicit SSL): encrypted from the first byte. It was deprecated, then un-deprecated, and it still works everywhere. Use it if 587 is blocked on your network.
- Port 25: the original relay port. Almost every residential ISP and cloud host blocks it outbound to stop spam. Don't build on it.
If sending fails and everything else looks right, the port is the first thing to check. A blocked 587 is the single most common cause.
Provider settings you're probably looking for
Most people searching for SMTP setup are wiring one specific mailbox into one specific app. The values you need:
Gmail / Google Workspace
- Host
smtp.gmail.com, port587(TLS) - Username: your full address
- Password: a 16-character App Password, not your login password
Since May 2025 Google no longer allows "less secure app" access, so if you have 2-Step Verification on (and you almost certainly do), a normal password will be rejected. You have to generate an app password from your Google account security page and use that. This trips up more first-time setups than anything else.
Microsoft 365 / Outlook
- Host
smtp.office365.com, port587, STARTTLS - Username and password: the mailbox credentials
- Watch out: many tenants have SMTP AUTH disabled by default and an admin has to turn it on per mailbox.
A dedicated sending provider
- Host, port, and a generated API-key-as-password from the provider's dashboard. This is the setup that scales, because it's built for application sending rather than a personal mailbox.
Why the mailbox route breaks down
Gmail and Outlook SMTP are fine for a contact form or a low-volume script. They fall apart the moment you're sending on behalf of a product.
Personal mailboxes cap sends at a few hundred a day, they aren't authenticated for your own domain, and the deliverability is tied to a reputation you don't control. Once you're past "the occasional automated email" you need a real sending path: your own verified domain, SPF and DKIM, and a server built to send at volume.
That's the point where SMTP setup stops being a settings problem and becomes an infrastructure problem.
The setup we'd rather you never do
I've built email tools for ten years. The SMTP-setup step is one everyone hates and no one remembers, because you do it once, forget the values, and re-google them the next time.
So at Nitrosend we made it a non-step. You connect an account from inside your AI agent and send a test email in the same breath. The CLI runs the connect-and-send from Claude, Codex, Cursor, or anything speaking MCP, and your first 8,000 emails go out from a shared sandbox before you've touched a DNS record. When you're ready for your own domain, the subdomain gets verified for authentication and your apex domain shows as the sender in the recipient's mail client.
No host to paste. No port to guess. No app password to regenerate at 11pm because Google rotated it.
If you want SMTP, we still speak SMTP. But the faster path is: describe the email, approve it, send it. The settings table above is here so you have it. The goal is that you never need it.
FAQ
What port should I use for SMTP?
Use 587 with STARTTLS for almost everything. Use 465 with SSL only if your network blocks 587. Avoid port 25. It's blocked outbound almost everywhere.
Why won't my Gmail SMTP password work?
If 2-Step Verification is on, Gmail rejects your normal password. Generate a 16-character App Password in your Google account security settings and use that instead.
Do I need SMTP to send email from my app?
No. SMTP is one way to hand email to a server. A modern email API or MCP-based tool sends over HTTPS, which is easier to authenticate, harder to get blocked, and doesn't need port or encryption configuration at all.
What's the difference between SMTP setup for a mailbox versus a sending service?
A mailbox (Gmail, Outlook) is built for a person and caps you at a few hundred sends a day on a reputation you don't own. A sending service authenticates your own domain and is built to send at volume with deliverability you control.