About
SMTP is a network protocol to send and receive mail between two hosts.
This page shows you the command and how you can interact with a SMTP server (MTA) in order to send an email
Example session
Step 1 - Connection
The first step is to connect to the SMTP server.
Without TLS
The port 25 is the default port of public server and should be configured without TLS
This port is normally only for receiving email but for test purpose on the localhost, it should be permitted to send an email.
Example with:
- netcat
nc localhost 25
- telnet
set localecho
set logfile c:\TelnetTest.txt
telnet localhost 25
With TLS
The submission port (ie where you can submit an email) is on:
- 487 with SSL
- and nowadays on 587 with TLS
Openssl has support for TLS over SMTP.
openssl s_client -connect server.example.com:587 -starttls smtp
Step 2 - Command
Server: Banner
After a successful connection, the SMTP server responds with a banner
220 server.example.com ESMTP Postfix
Client: EHLO
The remote SMTP client may introduce itself by giving its fully qualified domain name with the EHLO command (Extended HELO)
EHLO client.example.com
Server: Configuration
The SMTP server answer by advertising its configuration
250-server.example.com
250-PIPELINING
250-SIZE 10240000
250-AUTH DIGEST-MD5 PLAIN CRAM-MD5
...
Mail Creation
The SMTP command that defines the email and finish with a .
MAIL FROM:<[email protected]>
RCPT TO: <[email protected]> NOTIFY=success,failure
DATA
Subject: Test email
Body of the email
.
QUIT
QUIT
Command
- HELP - Get list of command
- HELO, - same as EHLO (deprecated)
- EHLO - Extended Helo - identify the SMTP client to the SMTP server with the the fully-qualified domain name as argument
of the SMTP client, if one is available.
- ETRN,
- MAIL FROM, Identifies the sender
- VRFY , verify the username exists on server
- RCPT TO, Identifies the recepient
- STARTTLS (used to tell the SMTP client that the SMTP server allows use of TLS. It takes no parameters. See Postfix - TLS (SSL) configuration)
- DATA (identified start of the message ie followed by a the body email
- SEND - send message to terminal
- RSET - Reset, abort connection and discard info
- NOOP - No operations, only elicits an OK from the server
- TURN
Generally forbidden (postconf.5.html)
- CONNECT,
- GET,
- POST
Login:
- AUTH LOGIN (then username password)