Applies to: any email address on your own domain (cPanel hosting, Google Workspace, Microsoft 365, your own mail server); lookups tested with dig 9.20.29 and nslookup on Debian 13
Your SMTP server (outgoing mail server) is shown in your email provider’s setup instructions and in your email app’s account settings. For cPanel hosting it is usually mail.yourdomain.com; for Gmail and Google Workspace it is smtp.gmail.com; for Microsoft 365 it is smtp.office365.com. The server that receives mail for a domain is a different thing: you find it in the domain’s MX record with dig MX yourdomain.com or nslookup -type=mx yourdomain.com.
Outgoing server or incoming server?
- Outgoing (SMTP submission) server: the server your email app, website or printer logs in to when it sends mail, on port 587 or 465 with your username and password.
- Incoming mail server (MX): the server other mail servers deliver to on port 25. Your email app then reads the mail over IMAP or POP3.
With hosting accounts both are often the same machine. With Google Workspace and Microsoft 365 the names are different.
1. Look it up at your email provider
- cPanel hosting: in cPanel open Email Accounts and click Connect Devices next to the address. The Secure SSL/TLS Settings show the outgoing server and SMTP port 465. According to cPanel’s documentation the name is your domain (such as
mail.example.com) when a valid SSL certificate covers it, otherwise the server’s host name. Step by step: find mail client settings in cPanel. - Gmail and Google Workspace:
smtp.gmail.com, port 465 (SSL) or 587 (TLS), with the full email address and, for devices and apps, an app password. Google Workspace also offerssmtp-relay.gmail.comfor relaying by IP address. - Microsoft 365:
smtp.office365.com, port 587 with STARTTLS. Microsoft says to use this name, not an IP address, notes that SMTP AUTH is off for organisations created after January 2020 (it can be switched on per mailbox) and that Basic authentication for SMTP AUTH is scheduled for deprecation. - Your own VPS or dedicated server: the SMTP server is the server itself (Postfix or Exim), reached by its host name.
Your email app already knows the server if the account works: look at the account’s server settings for “outgoing server” or “SMTP server”.
2. Find the incoming mail server (MX record)
On Linux or macOS:
$ dig +short MX gmail.com 40 alt4.gmail-smtp-in.l.google.com. 30 alt3.gmail-smtp-in.l.google.com. 5 gmail-smtp-in.l.google.com. 10 alt1.gmail-smtp-in.l.google.com. 20 alt2.gmail-smtp-in.l.google.com.
The number is the priority: senders try the lowest number first. On Windows (Command Prompt or PowerShell) use nslookup, which also works on Linux:
> nslookup -type=mx gmail.com Non-authoritative answer: gmail.com mail exchanger = 40 alt4.gmail-smtp-in.l.google.com. gmail.com mail exchanger = 30 alt3.gmail-smtp-in.l.google.com. gmail.com mail exchanger = 5 gmail-smtp-in.l.google.com. ...
A domain on Microsoft 365 shows a name ending in mail.protection.outlook.com; one on Google Workspace shows Google’s servers. To change the MX record, see add an MX entry in cPanel.
3. Find the IP address of a mail server
$ dig +short smtp.gmail.com 192.178.211.109 $ dig +short -x 192.178.211.109 lcbomp-in-f109.1e100.net.
Large providers answer from many addresses that change over time, so always configure the name, never the IP. The IP is useful for firewall rules on your own network or to check a blocklist. The second command (a reverse lookup) shows the name set for that IP.
4. See which server sent a message
Every mail server a message passes adds a Received: line at the top of the headers (RFC 5321), so the lowest Received: line is where the message started and the top one is the last hop. To open the headers:
- Gmail on a computer: next to Reply, click More > Show original.
- Outlook: open the message, then File > Properties; the headers are in Internet headers.
5. Test that the server answers
On Linux, nc (package netcat-openbsd on Debian and Ubuntu) connects to port 587 and prints the server’s greeting. Type EHLO with any name to see what the server supports, then QUIT. Output from our test, with our own IP address replaced:
$ nc smtp.gmail.com 587 220 smtp.gmail.com ESMTP ... - gsmtp EHLO test.example.com 250-smtp.gmail.com at your service, [203.0.113.25] 250-SIZE 35882577 250-STARTTLS ... QUIT
A 220 greeting means the server is reachable. If port 25 simply times out from your office or home connection, that is often the internet provider blocking it, as it did in our test; it doesn’t mean the server is down. From a server you can check outgoing port 25. Which port to use for what: SMTP port numbers explained.
Official documentation: cPanel Set Up Mail Client, Google Workspace: send email from a printer, scanner or app and Microsoft 365: send email from a device or application.