SMTP-server: what it is and how it works

SMTP server and email delivery

An SMTP server accepts email from a mail application or website and forwards it, usually to the recipient’s server. Applications submit messages on port 465 with TLS encryption from the start of the connection, or on port 587 with an upgrade to TLS through STARTTLS; mail servers exchange messages on port 25. For everyday correspondence, your email provider’s SMTP service is sufficient. Running your own server makes sense when your company is prepared to manage sending and maintain the infrastructure.

What is SMTP in simple terms?

SMTP stands for “Simple Mail Transfer Protocol”. It defines the rules programs use to transmit the sender’s address, recipients’ addresses and the message itself.

SMTP has two main tasks:

  • Accept outgoing mail from an application: an email client, a corporate system or a website sending an order confirmation.
  • Transfer messages between mail servers: from the sender’s system to the recipient’s system, sometimes through intermediate servers.

An SMTP server is the software that handles these connections, or the computer running it. Other services provide email storage and access.

SMTP does not let you read a mailbox. IMAP or POP3 handles that task. Spam filtering, antivirus scanning and archiving are features of particular mail software and its associated components, rather than of the protocol itself.


How an email is sent

Let’s look at a typical delivery from an email client to another organisation.

  1. The application connects to the submission server on port 465 or 587, using encryption and authentication.
  2. The server accepts the message into its queue and determines the next step in its route.
  3. The recipient’s server is located using MX records in the Domain Name System, DNS. If there are several records, their priorities are taken into account.
  4. The message is transferred over SMTP on port 25. TLS may protect the connection.
  5. The message is delivered to the mailbox, where the recipient can read it.

Component names: MUA is the user’s mail application, MTA is the mail transfer agent, and MDA is the agent that delivers messages to a mailbox.

If the recipient’s server is temporarily unavailable, the message remains queued for further delivery attempts. Acceptance by the next server does not guarantee that it will appear in the inbox or be read.

An SMTP session: commands and response codes

The commands and response codes are described in RFC 5321. Here is an example session on port 587: “C” is the client and “S” is the server. Explanations in brackets are not transmitted over the network.

S: 220 smtp.example.net ESMTP
C: EHLO client.example.org
S: 250-smtp.example.net
S: 250 STARTTLS
C: STARTTLS
S: 220 Ready to start TLS
[TLS is established]
C: EHLO client.example.org
S: 250-smtp.example.net
S: 250 AUTH PLAIN
[The client performs AUTH; credentials are not shown]
S: 235 2.7.0 Authentication successful
C: MAIL FROM:<[email protected]>
S: 250 2.1.0 Ok
C: RCPT TO:<[email protected]>
S: 250 2.1.5 Ok
C: DATA
S: 354 End data with <CR><LF>.<CR><LF>
C: From: [email protected]
C: To: [email protected]
C: Subject: Test
C:
C: Test message.
C: .
S: 250 2.0.0 Queued
C: QUIT
S: 221 2.0.0 Bye

EHLO supplies the client’s name and requests the server’s capabilities. After STARTTLS, the client repeats EHLO because the available extensions may change. For example, servers often advertise AUTH, which authenticates the account, only within a TLS connection. These extensions are defined in RFC 3207 and RFC 4954.

MAIL FROM and RCPT TO specify delivery addresses: the message’s “envelope”. From and To are headers inside the message that the user sees. They may differ from the envelope: a blind-copy recipient’s address does not appear in To.

After DATA, a 354 response permits the client to transmit the contents; a blank line separates the headers from the body. A full stop on a line of its own ends transmission, 250 confirms acceptance by this server, and QUIT and 221 close the session.

Incoming and outgoing mail servers

The outgoing server in your application’s settings accepts messages over SMTP. The incoming server provides access to the mailbox over IMAP or POP3. Mail from other domains also arrives over SMTP: “incoming” in the application’s interface refers to the user’s access to the mailbox.

IMAP lets you work with messages and folders on the server, synchronising changes between devices. POP3 primarily downloads messages to the application; whether copies remain on the server depends on the settings. IMAP is usually more convenient when you use both a phone and a computer for email. Neither protocol replaces SMTP for sending messages.

Get Expert Help
Choosing the Right Equipment

Our specialists will contact you and answer all your questions

I agree to process my personal data

SMTP ports: 25, 465 and 587

SMTP ports and encryption modes

A port directs a connection to the appropriate service. Standard SMTP connections use TCP.

Port Purpose Encryption
25 Transfer between mail servers TLS through STARTTLS, depending on the capabilities and policies of both sides
587 Submission from an email client or application, usually with authentication Upgrade to TLS through STARTTLS; the client must require encryption
465 Submission from an email client or application, usually with authentication; often called SMTPS TLS immediately, before the SMTP dialogue
2525 An additional port offered by some SMTP services The provider defines the mode; it is not a universal replacement for other ports

The distinction between server-to-server transfer and user submission is established in RFC 6409. Use port 2525 only if the service supports it.

Which should you choose: 465 or 587?

Both options are valid: TLS starts immediately on port 465 and after STARTTLS on port 587. According to RFC 8314, there is no significant difference in security when establishing TLS is mandatory.

Use the combination of port and encryption mode specified in your provider’s documentation. Expecting TLS from the first byte on port 587 can cause an error. Encryption must be required when transmitting a password.

Why port 25 may be blocked

Internet providers and cloud platforms may restrict outbound connections to port 25 to combat spam. Check the platform’s documentation before deploying a server.

An application usually needs only port 465 or 587. Direct delivery requires access to port 25 on external servers: outbound port 587 does not replace it. An authorised external SMTP service is an alternative.

How to find your SMTP server address

Obtain the address from your email provider: it does not have to match your mailbox’s domain. Check:

  • the email provider’s instructions for connecting applications;
  • the outgoing mail settings in an application that already works;
  • the mail or hosting control panel;
  • your corporate administrator’s instructions.

Do not guess the address using a pattern such as smtp.your-domain.com. An MX record identifies the server receiving mail from other servers, which is not necessarily the endpoint used by users to submit outgoing messages.

The settings below were checked against official documentation in November 2026. Addresses and policies may differ in a corporate deployment.

Email service SMTP server address Port and connection security
Microsoft Outlook smtp-mail.outlook.com 587 — STARTTLS
Gmail smtp.gmail.com 465 — immediate TLS; 587 — STARTTLS

An immediate TLS connection may be labelled “SSL” or “SSL/TLS”. This is the name of a setting, rather than a recommendation to use obsolete SSL.

SMTP username and password

The username identifies an account authorised to send mail.

Your main webmail password does not always work:

  • Microsoft Outlook.com requires OAuth 2.0 authentication: select this sign-in method in your email application’s settings instead of a standard password.
  • Gmail supports OAuth: signing in through Google without giving the application your main password. App passwords are available with two-step verification, subject to account restrictions.

An SMTP service may use access keys. If authentication fails, check the password, sign-in method, application permissions and permitted sender address.

Types of SMTP servers and email delivery services

SMTP services and mail relaying

Your choice depends on the type of email you send and who will manage delivery.

An email provider’s or hosting provider’s server is suitable for correspondence. The provider maintains the infrastructure. Having a mailbox does not automatically permit bulk sending.

A specialised delivery service handles notifications and permission-based campaigns. Compare limits, statistics, bounce handling, complaints, unsubscribes and domain requirements.

Your own server gives you control over routes, logs and the queue. Your company is responsible for security and updates; an external service can handle delivery to other systems.

An IP address may be shared with other customers or dedicated. A shared IP’s reputation also depends on other users; you maintain a dedicated IP’s reputation yourself. A dedicated address does not guarantee inbox placement.

Check the plan’s terms for limits on message count, recipients and sending rate.

SMTP relay and SMTP gateway

SMTP relay means forwarding mail through an intermediate server. For example, an office server can collect messages from applications and send them through a provider.

An SMTP gateway applies rules at the system boundary: filtering, attachment checks and sending restrictions. This is a software role, rather than a separate protocol; a gateway may also act as a relay.

An open relay forwards third-party mail to third-party domains without access controls. Spammers exploit it, which can lead to IP blocking. Accepting external messages for your own users is normal.


Security: TLS, SPF, DKIM and DMARC

Connection encryption, account authentication and domain validation address different tasks. No single mechanism protects the entire email system.

TLS and authentication

TLS protects a particular connection hop. STARTTLS is the command that upgrades the connection to TLS, rather than a separate encryption algorithm. The client must verify the certificate, including the server name, and stop sending if security validation fails.

TLS protects individual hops along the route and does not hide message contents from the mail systems processing them.

SMTP AUTH authenticates the application’s account. The server’s policy determines which From addresses are permitted. Store passwords and keys in protected settings, keeping them out of public code and logs.

SPF: authorised sending sources

SPF describes authorised sending sources in DNS. The recipient compares the sending server’s IP address with the rules for the SMTP envelope domain; HELO/EHLO checks are also supported. The mechanism is defined in RFC 7208.

SPF does not check message contents and does not, by itself, authenticate the visible From address. Include mail, website and notification services in your rules. Forwarding may change the result because the connecting server changes.

DKIM: a message signature

DKIM associates a message with the signing domain. The sending system signs selected headers and the body using a private key; the recipient checks the signature using a public key published in DNS. The core mechanism is described in RFC 6376.

The signature confirms an association with the domain and the integrity of the signed data, rather than the safety of the contents or the employee’s identity. Changes to that data may cause verification to fail.

DMARC: checking the visible sender

DMARC compares the domain in the visible From address with the domains authenticated through SPF or DKIM. One successful check with appropriate domain alignment is sufficient to pass. The domain owner publishes a policy for handling messages that fail and can receive reports.

Introduce a strict policy after checking legitimate sending channels, so that you do not block your own messages. Passing DMARC does not guarantee inbox placement.

PTR and server-to-server protection

A PTR record associates an IP address with a domain name in a reverse DNS lookup. The IP owner or provider usually configures it. The name should resolve back to the server’s address; reverse DNS errors may cause recipients to reject mail.

MTA-STS lets a domain publish a requirement for server-to-server delivery using TLS and certificate validation; senders supporting the mechanism can apply it.

Get Expert Help
Choosing the Right Equipment

Our specialists will contact you and answer all your questions

I agree to process my personal data

How to test an SMTP server

Testing an SMTP server

Port availability, encryption, authentication and delivery are separate stages. Start with the connection.

Testing the connection and TLS

For a server using STARTTLS on port 587, use OpenSSL:

openssl s_client -connect smtp.example.net:587 -starttls smtp -servername smtp.example.net -verify_hostname smtp.example.net -verify_return_error -crlf

Replace smtp.example.net with your own address in all three places. This checks STARTTLS, the certificate and the hostname. On port 465, TLS must start immediately:

openssl s_client -connect smtp.example.net:465 -servername smtp.example.net -verify_hostname smtp.example.net -verify_return_error -crlf

A successful check usually returns Verify return code: 0 (ok). If it fails, also check your local trusted certificate store.

Enter EHLO client.example.org, review the capabilities and end the session with QUIT. On port 587, the program performs the initial STARTTLS exchange itself. No password is required; authentication and delivery are not tested.

To view the initial unencrypted SMTP greeting on port 25, you can use:

telnet mail.example.net 25

The response starts with 220. Telnet does not establish TLS: do not enter a password. If there is no response, check DNS, network restrictions and the service.


Online tests assess DNS and connectivity from the service’s network: results from your office may differ. Test actual sending by delivering a test message to your own mailbox and reviewing delivery events.

SMTP errors

Read the server’s full response and consider the stage at which the failure occurred. 4xx indicates a temporary error that permits a retry; 5xx indicates a permanent failure for that attempt, whose cause must be addressed.

  • 421 or 451: temporary unavailability or a processing error. Mail software may defer delivery.
  • 535: authentication failure. Possible causes include incorrect credentials, an unsuitable sign-in method or account restrictions.
  • 550: for example, a missing mailbox, relaying prohibited or a security policy. Check the response text and enhanced status code for the exact meaning.

Find an accepted message by its identifier in the queue, logs or service events. If delivery fails, examine the next server’s response in the failure notification.

Your own SMTP server: when you need one

You need your own server when you require control over routing, logs, storage and processing rules, and have specialists to maintain it. A high sending volume alone does not make it better value than a service.

A notification-sending server and a corporate mail system with mailboxes are different projects. The latter also needs storage, IMAP, user management and backups.

What you will need

To exchange mail independently with external mail systems, you need:

  • a server or virtual machine running a supported operating system;
  • a static public IP address, the ability to configure PTR and forward DNS records;
  • MX records for receiving mail for the domain; SPF, DKIM and DMARC for sending configuration and domain authentication;
  • outbound access to port 25 on external servers and, if receiving mail, inbound access to your own port 25;
  • a TLS certificate, authentication and relaying restrictions;
  • mail software, queue monitoring, updates and backups.

Unix-like systems can use Postfix or Exim, for example. For Windows, choose a product with current operating system support, updates and a suitable licence. Installing mail transfer software alone does not create a complete corporate mail system.

How to choose hardware and organise deployment

To host email within your company, consider office servers. The configuration depends on user count, storage capacity, attachments, sending volume and filtering. These factors are discussed in “How to Choose a Server for a Small Business or Office”.

For a mail virtual machine, account for neighbouring workloads. If rack space is limited, consider the 1U HPE ProLiant DL360 Gen10; for more drive and expansion space, consider the 2U HPE ProLiant DL380 Gen10. Check the configuration and software compatibility; for more on the platforms, see “HPE ProLiant DL380: Comparing Gen9–Gen12”.

Server hardware in a data centre

Example of server hardware. Photo source: panumas nikhomkhai / Pexels.

First arrange the IP address, PTR and platform restrictions, then configure the domain, encryption and access. Before migrating correspondence, test sending and receiving, SPF, DKIM, DMARC, protection against unauthorised relaying and recovery from a backup.

Frequently asked questions

How does SMTP differ from POP3 and IMAP?

SMTP transfers messages from an application to a server and between servers. POP3 and IMAP give an application access to messages in a mailbox. Sending and reading usually require separate connection settings.

Can a website send email through SMTP?

Yes. The website connects to an authorised server using encryption and authentication. Use separate credentials and an approved sender address; the domain’s configuration must account for this sending channel.

Why do messages go to spam even though SMTP works?

SMTP acceptance does not guarantee inbox placement. The recipient considers domain authentication, reputation, content and complaints. Examine the message headers and delivery events.

What is EHLO?

It is the command a client uses to introduce itself to the server and request extensions: STARTTLS, authentication methods and other capabilities. EHLO is sent again after upgrading to TLS.

Why is port 25 not working?

Possible causes include provider restrictions, a network filter or a stopped service. For sending from an application, use the provider’s recommended port 465 or 587; for direct server-to-server delivery, ask the platform about access to port 25.

How to choose a sending method

For everyday correspondence, use your email provider’s SMTP service. Choose your own system when you need control over email and are prepared to maintain it continuously.


Get Expert Help
Choosing the Right Equipment

Our specialists will contact you and answer all your questions

I agree to process my personal data
Comments
(0)
No comments
Write the comment
I agree to process my personal data

Next news

Be the first to know about new posts and earn £50