New guide: how to warm up a dedicated IP without hurting your reputation. Read now →
Log in
MigoSMTP
SMTP and APIUpdated 4 Nov 2026

SMTP settings for major email providers: host, port and security cheat sheet

SMTP host names, ports and encryption modes for Gmail, Outlook.com, Microsoft 365, Yahoo, iCloud, Zoho and AOL, with guidance on choosing 587 or 465, authentication rules and fixing common sending errors.

SM
Written by Sofia Marino
Technical Support Lead
Reviewed by Kwame Mensah
  • Published22 Nov 2023
  • Read time7 min
  • Length1,388 words
Share this guide

For outgoing mail, use your provider's SMTP host on port 587 with STARTTLS, or port 465 with implicit SSL/TLS if the provider offers it. Authenticate with your full email address and an app password or OAuth, and set the From address to the account you sign in with. Port 25 is for server-to-server delivery and is blocked by many networks, so avoid it for client submission.

The table below lists the main providers. Hostnames and authentication rules do change, and administrators can disable options on business accounts, so confirm against the provider's current documentation when something fails. The rest of the article explains how to pick between 587 and 465, what authentication to expect and how to read the common errors.

Port 587Submission with STARTTLS. The usual default for clients and apps
Port 465Submission with implicit TLS. Supported by many providers
Port 25Server-to-server relay. Often blocked for end users
AuthenticationRequired on 587 and 465, using an app password or OAuth

SMTP host and port by provider

ProviderSMTP hostPorts and securityAuthentication notes
Gmail and Google Workspacesmtp.gmail.com465 SSL/TLS, 587 STARTTLSApp password with 2-Step Verification, or Google sign-in (OAuth)
Outlook.com, Hotmail, Livesmtp-mail.outlook.com587 STARTTLSModern authentication is replacing passwords for consumer accounts
Microsoft 365smtp.office365.com587 STARTTLSAuthenticated SMTP must be enabled for the mailbox by the administrator
Yahoo Mailsmtp.mail.yahoo.com465 SSL/TLS, 587 STARTTLSApp password required
iCloud Mailsmtp.mail.me.com587 STARTTLSApp-specific password, with the full iCloud address as username
Zoho Mailsmtp.zoho.com465 SSL/TLS, 587 STARTTLSRegional domains such as smtp.zoho.eu and smtp.zoho.in exist, and paid organisation accounts may use a different host
AOL Mailsmtp.aol.com465 SSL/TLS, 587 STARTTLSApp password required

More detail on individual providers: Gmail SMTP settings and Outlook and Microsoft 365.

Choosing between port 587 and port 465

Both ports are for mail submission, meaning a client or application handing a message to its own provider. Port 587 begins as a plain connection and upgrades with the STARTTLS command. Port 465 is encrypted from the first byte. RFC 8314 recommends implicit TLS for submission, and RFC 6409 defines port 587 for message submission, so both are valid.

Question587 with STARTTLS465 with implicit TLS
Encryption startsAfter the STARTTLS commandImmediately
Client setting nameSTARTTLS or TLS if availableSSL/TLS or SSL
Risk of mistakesDowngrade if the client allows plain fallbackFew, since there is no plain phase
SupportAlmost universalWide, but not offered by every provider
Firewall behaviourUsually open on consumer networksUsually open, sometimes less commonly allowed in strict networks

If your library offers a choice, require encryption rather than opportunistic encryption. Opportunistic STARTTLS can be stripped by an attacker on the path, while a required setting makes the connection fail instead.

Authentication: what to expect

  • Username. Usually the full email address.
  • Password. Many providers no longer accept the ordinary account password in third-party clients. Use an app password. See app passwords explained.
  • OAuth 2.0. Where available, sign-in happens in the provider's page and the client holds a token. See OAuth 2.0 for SMTP and IMAP.
  • From address. Most providers rewrite or reject a From address that does not belong to the signed-in account, unless you have configured an alias.
  • Business accounts. Administrators can disable SMTP authentication, require OAuth or restrict who may send. If your settings are correct and still fail, ask your administrator.

Test your settings from the command line

Before changing an application, check that the server accepts your login. This example uses curl against the Gmail server and a throwaway message file. Replace the values, and use an app password.

cat > msg.txt <<'EOF'
From: [email protected]
To: [email protected]
Subject: SMTP test

Test message.
EOF

curl --ssl-reqd --url 'smtps://smtp.gmail.com:465' \
  --user '[email protected]:APP_PASSWORD' \
  --mail-from '[email protected]' --mail-rcpt '[email protected]' \
  --upload-file msg.txt

For STARTTLS on 587, change the URL to smtp://smtp.gmail.com:587 and keep --ssl-reqd. The same pattern works for the other providers by changing the host and credentials. A success returns without errors, and a failure prints the SMTP reply code, which you can look up in an SMTP reply code reference.

Configuration in code

Most libraries need the same few values. This Python example uses implicit TLS and reads the secret from the environment.

import os, smtplib
from email.message import EmailMessage

msg = EmailMessage()
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
msg['Subject'] = 'SMTP test'
msg.set_content('Test message.')

with smtplib.SMTP_SSL('smtp.example.com', 465, timeout=30) as s:
    s.login('[email protected]', os.environ['SMTP_PASSWORD'])
    s.send_message(msg)

For STARTTLS, use smtplib.SMTP(host, 587), then call starttls() before login().

Common mistakes with hostnames and usernames

  • Using the incoming server for sending. An IMAP or POP host such as imap.example.com does not accept submission. SMTP has its own host.
  • Using an alias as the username. Many providers authenticate only the primary address. Sign in with the main mailbox and add the alias as an allowed From address.
  • Typing the password with auto-correct. Mobile keyboards capitalise or insert spaces into app passwords. Remove the spaces that providers add for readability when they display a code in groups.
  • Leaving authentication switched off. A setting such as my outgoing server requires authentication must be ticked in many desktop clients.
  • Pointing at a generic hosting server. For a custom domain on shared hosting, the SMTP host is usually given in the hosting control panel, not by Gmail or Outlook.

How custom domains and shared hosting differ

The providers in the table are mailbox services. If your address is on your own domain, the SMTP host depends on where that mailbox lives. If the mailbox is hosted by Google Workspace or Microsoft 365, use those hosts with your domain address as the username. If it lives at a web host, use the hostname and ports shown in the hosting panel, and check whether the host blocks outbound port 25 or limits hourly sending.

A frequent surprise is that mail sent through a web host's SMTP server for a domain whose DNS points elsewhere fails SPF or DKIM checks at the receiver. The sending IP must be authorised by the domain's SPF record, and the DKIM signature must match a published key. Without that, messages are accepted by your server but quarantined by the recipient.

Limits you will meet on personal and business mailboxes

Personal mailbox SMTP is designed for people, not for applications. Providers set daily recipient limits, rate limits and rules about bulk content, and they change these over time. Check the provider's current documentation for exact numbers rather than relying on a figure from memory. If you are sending newsletters, invoices from an application or password resets at volume, a dedicated sending service with its own credentials and event reporting is the more reliable route. See when to switch from Gmail or Outlook to a sending service.

Troubleshooting

Error or symptomLikely causeFix
535 authentication failedWrong password, no app password, or basic auth disabledCreate an app password or use OAuth. See SMTP 535 authentication failed
530 must issue STARTTLS firstClient connected on 587 without enabling STARTTLSEnable STARTTLS or encryption in the client. See 530 5.7.0 fix
Connection timed outPort blocked by firewall or ISP, or wrong hostTry the alternate port, another network or check the hostname
Handshake or SSL errorSTARTTLS selected for 465, or implicit TLS for 587Match the mode to the port
Certificate name mismatchWrong hostname or a proxy intercepting TLSUse the provider hostname exactly as documented
553 or 550 sender rejectedFrom address does not belong to the accountSend from the signed-in address or configure an alias
Authentication disabled message on Microsoft 365Authenticated SMTP off for the mailboxAdministrator must enable authenticated SMTP (client submission) for the mailbox

Security checklist and next steps

  • Require TLS on every connection and never fall back to plain text.
  • Store credentials in environment variables or a secret manager, not in the repository.
  • Use a separate app password per application, and revoke it when the application is retired.
  • Do not disable certificate validation to make an error go away. Fix the hostname or the trust store.
  • Set up SPF, DKIM and DMARC for any domain that sends mail so that receivers can verify it.

Once the connection works, the next question is reputation. Mail that is accepted by your provider can still land in spam if the domain is not authenticated. Read authenticating your sending domain for the records you need.

Need SMTP for an application? Get relay credentials on ports 587 and 465 with delivery, bounce and complaint events.

Explore the SMTP relay

References and further reading

Frequently asked questions

Should I use port 587 or 465?

Either is valid. 587 with STARTTLS is the most widely supported, and 465 with implicit TLS is simpler and encrypted from the start.

What is the Gmail SMTP server?

smtp.gmail.com, port 465 with SSL/TLS or port 587 with STARTTLS, using an app password or Google sign-in.

Why is port 25 not recommended for mail clients?

It is meant for server-to-server delivery and is often blocked by ISPs and cloud networks for end users.

Do I need an app password for SMTP?

For Gmail, Yahoo, iCloud and AOL, generally yes, unless the client supports OAuth sign-in.

Why does my SMTP login fail when the password is right?

The provider may require an app password or OAuth, or an administrator may have disabled authenticated SMTP.

Topics#smtp#ports#starttls#mail client#gmail#outlook#yahoo#icloud#zoho
Was this guide helpful?Your answer helps us improve our documentation.

Start sending in minutes.

Create an account, add your domain and send your first email.

Get started Talk to sales