WhichWebHosting home

HomeGuidesEmail hostingWhat is SMTP?

What is SMTP?

Published

Share

SMTP stands for Simple Mail Transfer Protocol.1, source 1 The objective of SMTP is to transfer mail reliably and efficiently.1, source 1 With SMTP, a mail message may pass through a number of intermediate relay or gateway hosts on its path from sender to ultimate recipient.1, source 1

What does SMTP stand for and what does it do?

RFC 5321 is a specification of the basic protocol for Internet electronic mail transport.1, source 1 SMTP is independent of the particular transmission subsystem and requires only a reliable ordered data stream channel.1, source 1 RFC 5321 specifically discusses SMTP transport over TCP, though other transports are possible.1, source 1 SMTP transports a mail object, which contains an envelope and content.1, source 1

The SMTP content is sent in the SMTP DATA protocol unit and has two parts: the header section and the body.1, source 1 An important feature of SMTP is its capability to transport mail across multiple networks, usually referred to as SMTP mail relaying.1, source 1 SMTP servers and clients provide a mail transport service and therefore act as Mail Transfer Agents (MTAs).1, source 1 Mail User Agents (MUAs) are normally thought of as sources and targets of mail.1, source 1

How does an SMTP conversation work?

An SMTP session is initiated when a client opens a connection to a server and the server responds with an opening message.1, source 1 The sending side of an SMTP exchange is the SMTP client, and the receiving side is the SMTP server.1, source 1 After the server's greeting, the client normally sends the EHLO command to identify itself.1, source 1 A client must issue HELO or EHLO before starting a mail transaction.1, source 1

Using EHLO also indicates that the client can process service extensions and asks the server to list the extensions it supports.1, source 1 An SMTP mail transaction has three steps.1, source 1 The transaction starts with a MAIL command that gives the sender identification.1, source 1 A series of one or more RCPT commands follows the MAIL command, giving the receiver information.1, source 1

Whenever a RCPT command appears without a previous MAIL command, the server must return a 503 Bad sequence of commands response.1, source 1 A DATA command initiates transfer of the mail data.1, source 1 When the server accepts DATA, it returns a 354 Intermediate reply and treats the following lines up to the end-of-data indicator as the message text.1, source 1 SMTP indicates the end of the mail data by sending a line containing only a period.1, source 1

Once the server issues a success response at the end of the mail data, it must accept responsibility for either delivering the message or properly reporting the failure to do so.1, source 1 The RSET command aborts the current mail transaction, and any stored sender, recipients and mail data are discarded.1, source 1 The QUIT command makes the receiver send a 221 reply and then close the transmission channel.1, source 1

What do SMTP reply codes mean?

Every SMTP command must generate exactly one reply.1, source 1 The number in an SMTP reply is for use by programs, and the text is usually intended for human readers.1, source 1 An SMTP client must determine its actions only by the reply code, not by the text, with exceptions for the 251 and 551 replies and, when necessary, the 220, 221 and 421 replies.1, source 1 The first digit of an SMTP reply code denotes whether the response is good, bad, or incomplete.1, source 1

A client must be prepared to handle reply codes not specified in RFC 5321 by interpreting the first digit only.1, source 1 A 2yz reply is a Positive Completion reply, meaning the requested action has been successfully completed.1, source 1 A 250 reply means the requested mail action is okay and completed.1, source 1 A 3yz reply is a Positive Intermediate reply, meaning the command was accepted but the requested action is on hold pending further information.1, source 1

A 354 reply tells the client to start mail input.1, source 1 A 4yz reply is a Transient Negative Completion reply: the command was not accepted, the error is temporary, and the action may be requested again.1, source 1 A 421 reply means the service is not available and the transmission channel is closing.1, source 1 A 5yz reply is a Permanent Negative Completion reply: the command was not accepted and the requested action did not occur.1, source 1

A 550 reply means the requested action was not taken because the mailbox is unavailable, for example not found, no access, or a command rejected for policy reasons.1, source 1

How does SMTP find the right server and handle failures?

An SMTP client determines the address of the server for a message by resolving the destination domain name to either an intermediate Mail eXchanger host or a final target host.1, source 1 A DNS lookup must be performed to resolve the destination domain name, and the lookup first attempts to locate an MX record.1, source 1 In an MX record, lower preference numbers are more preferred than higher ones.1, source 1 When a domain has no MX records, the address is treated as if it had an implicit MX record with a preference of 0 pointing to that host.1, source 1

Whenever several MX records share the same preference with no clear reason to favor one, the sending SMTP must randomize them to spread the load across mail exchangers.1, source 1 A relay SMTP server is usually the target of a DNS MX record that designates it, rather than the final delivery system.1, source 1 An SMTP server can be either the ultimate destination or an intermediate relay, which assumes the role of an SMTP client after receiving the message.1, source 1 A relay SMTP server must not inspect or act on the header section or body of the message, except to add its own Received header field and optionally to detect looping.1, source 1

Mail that cannot be transmitted immediately must be queued and periodically retried by the sender.1, source 1 After a failed attempt, the retry interval should in general be at least 30 minutes.1, source 1

The give-up time for retrying a message generally needs to be at least 4 to 5 days.1, source 1 Whenever an SMTP server has accepted the task of relaying a message and the mail cannot be delivered, it must send an undeliverable mail notification to the originator.1, source 1

Which port does SMTP use?

IANA specifies port 25 as the SMTP port, and an SMTP server should attempt to keep a pending listen on it at all times.1, source 1 SMTP was defined as a message transfer protocol, a means to route and deliver finished messages.2, source 2 SMTP is also widely used as a message submission protocol, a means for Message User Agents to introduce new messages into the Message Transfer Agent routing network.2, source 2 The process that accepts message submissions from mail clients is termed a Message Submission Agent (MSA).2, source 2

Port 587 is reserved for email message submission, and messages received on this port are defined to be submissions.2, source 2 Submission on port 587 uses ESMTP, with additional restrictions or allowances specified in RFC 6409.2, source 2 Most email clients and servers can be configured to use port 587 instead of port 25.2, source 2 A site may choose to use port 25 for message submission by designating some hosts to be submission agents and others to be transfer agents.2, source 2

Many sites prohibit outbound traffic on port 25 and funnel all mail submissions through submission servers, because of machines infected with worms, viruses or other malicious software that generate spam.2, source 2 A submission server must, by default, return an error to the MAIL command when the session has not been authenticated using SMTP AUTH, unless authentication or authorization was already established another way.2, source 2 Methods used to restrict submission to authorized senders include authenticated SMTP, IP address restrictions, secure IP and other tunnels, and prior POP authentication.2, source 2 In the split-MUA model, POP or IMAP is used to access delivered messages, while SMTP or the submission protocol is used to submit messages.2, source 2

The default port for the submissions service, SMTP submission with Implicit TLS, is 465.3, source 3 Implicit TLS means TLS is negotiated automatically whenever a TCP connection is made on a port used exclusively by that server for TLS connections.3, source 3 With STARTTLS, the client first opens a cleartext session, and if the client issues a STARTTLS command, a TLS handshake follows that can upgrade the connection.3, source 3 STARTTLS on port 587 is relatively widely deployed.3, source 3

RFC 8314 says clients and servers should implement both STARTTLS on port 587 and Implicit TLS on port 465 during a transition period.3, source 3 There is no significant difference between the security properties of STARTTLS on port 587 and Implicit TLS on port 465 if the implementations are correct and if both the client and the server are configured to require successful negotiation of TLS prior to message submission.3, source 3 RFC 8314 recommends TLS version 1.2 or greater for all traffic between mail clients and mail submission servers.3, source 3 Mail service providers that support cleartext SMTP on port 25 for message submission should move the people who submit mail that way to TLS as soon as practicable.3, source 3

Is SMTP secure, and where do SPF, DKIM and DMARC fit?

SMTP mail is inherently insecure in that it is feasible to negotiate directly with receiving and relaying SMTP servers and create messages that will trick a naive recipient into believing they came from somewhere else.1, source 1 Existing email protocols place no restriction on what a sending host can use as the MAIL FROM of a message.4, source 4

Sender Policy Framework (SPF)

SPF stands for Sender Policy Framework.4, source 4 SPF lets a domain explicitly authorize the hosts allowed to use its domain names, and lets a receiving host check that authorization.4, source 4 An SPF record is a DNS record that declares which hosts are, and are not, authorized to use a domain name for the HELO and MAIL FROM identities.4, source 4

SPF records must be published as a DNS TXT record (type 16) only.4, source 4 An SPF implementation must limit the terms that cause DNS queries to 10 during evaluation, and exceeding the limit produces a permerror result.4, source 4

DomainKeys Identified Mail (DKIM)

DKIM stands for DomainKeys Identified Mail.5, source 5 DKIM lets a person, role or organization that owns the signing domain claim some responsibility for a message by associating the domain with the message.5, source 5 DKIM validates the assertion of responsibility through a cryptographic signature and by querying the signer's domain for the public key.5, source 5 A DKIM signature is stored in the DKIM-Signature header field of the message.5, source 5

In a DKIM signature, the s= tag holds the selector, which subdivides the namespace for the domain in the d= tag.5, source 5 DKIM public keys are stored in a subdomain named _domainkey.5, source 5 A DKIM signature failure does not force rejection of the message.5, source 5

Domain-based Message Authentication, Reporting, and Conformance (DMARC)

DMARC stands for Domain-based Message Authentication, Reporting, and Conformance.6, source 6 Domain owners publish their DMARC policy in a DNS TXT record at the _dmarc subdomain, for example _dmarc.example.com.6, source 6 DMARC receivers compare the RFC5322.From address in the mail to the SPF and DKIM results, if present, and the DMARC policy in DNS.6, source 6

DMARC policy p=none means the domain owner requests no specific action regarding delivery of messages.6, source 6 DMARC policy p=quarantine asks receivers to treat mail that fails the DMARC check as suspicious.6, source 6 DMARC policy p=reject asks receivers to reject mail that fails the DMARC check, and rejection should occur during the SMTP transaction.6, source 6

What are the SMTP settings for Google Workspace and Microsoft 365?

Google Workspace administrators can set up devices and apps in their organization to send email through Google Workspace.7, source 7 Google's SMTP relay service authenticates messages with IP addresses, so devices and apps can send messages to anyone inside or outside the organization.7, source 7 The fully qualified domain name of Google's SMTP relay service is smtp-relay.gmail.com.7, source 7 Devices and apps connect to smtp-relay.gmail.com on port 25, 465 or 587.7, source 7

On the Gmail SMTP server option, the server address to enter on the device or in the app is smtp.gmail.com.7, source 7 On the Gmail SMTP server, the SSL setting uses port 465 and the TLS setting uses port 587.7, source 7 On the Gmail SMTP server option, the authentication setup uses your complete Google Workspace email address and an app password.7, source 7

The restricted Gmail SMTP server option lets an organization send messages only to people who use Gmail or Google Workspace, and it does not require authentication.7, source 7 For the restricted Gmail SMTP server option, the SPF record for your domain must include the IP address or domain of the device or app sending messages, and must reference all senders for the domain.7, source 7 If a device or app does not support SSL, the restricted Gmail SMTP server aspmx.l.google.com must be used.7, source 7

For client SMTP submission with Microsoft 365 or Office 365, port 587 (recommended) or port 25 is required and must be unblocked on your network.8, source 8 Some network firewalls or ISPs block port 25 because email servers use that port to send messages.8, source 8 For client SMTP submission with Microsoft 365 or Office 365, the device or application must support TLS 1.3 or TLS 1.2.8, source 8 Microsoft 365 and Office 365 client SMTP submission uses the DNS name smtp.office365.com, not an IP address.8, source 8

Microsoft 365 and Office 365 SMTP relay requires port 25.8, source 8

Common questions

What is the full form of SMTP?

The full form is Simple Mail Transfer Protocol. Its objective is to transfer mail reliably and efficiently.

What does an SMTP server do?

An SMTP server receives mail from an SMTP client. The server acts as either the final destination or an intermediate relay that assumes the role of a client to pass the mail on.

Which port should an email program use to send mail?

Port 587 is reserved for message submission. Port 465 is the default for message submission with implicit TLS.

Can one SMTP server send mail to another?

Yes, an SMTP server can relay mail. An intermediate relay takes on the role of an SMTP client after receiving the message, and a message may pass through a number of relay or gateway hosts on its path to the ultimate recipient.

What does SMTP error 550 mean?

It means the mailbox is unavailable. The requested action was not taken. This includes instances where the mailbox is not found, there is no access, or a command is rejected for policy reasons.

Does SMTP encrypt email?

Sometimes. Message submission from a mail program can use encryption through TLS, either with Implicit TLS on port 465 or with STARTTLS on port 587, where a TLS handshake can upgrade a cleartext session.

More guides

Email hosting

Does 123 Reg hosting include email?

123 Reg's Web Hosting, Hosting for WordPress and Premium Hosting plans include email addresses, and 123 Reg sells Titan and Microsoft 365 email plans.

· Mateo Cardenas

Email hosting

Does web hosting include business email?

Web hosting sometimes includes business email. See what SiteGround, Namecheap and HostGator state, then how MX records and SPF records work.

· Mateo Cardenas

Email hosting

How to log in to Hostinger webmail

Find out how to log in to Hostinger Webmail at mail.hostinger.com, access your inbox directly from hPanel, and connect third-party mail apps via IMAP.

· Mateo Cardenas

Email hosting

How to log in to IONOS webmail

Learn how to log in to IONOS webmail at mail.ionos.com, manage automatic login, use two-step verification, and apply the right server settings for email.

· Mateo Cardenas