Email - Smtp Protocol

1 - About

SMTP is a network protocol to send and receive mail between two hosts that is implemented by a MTA

This page shows you the command and how you can interact with a SMTP server in order to send an email

3 - Example session

3.1 - Step 1 - Connection

The first step is to connect to the SMTP server.

3.1.1 - 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

3.1.2 - 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

3.2 - Step 2 - Command

3.2.1 - Server: Banner

After a successful connection, the SMTP server responds with a banner


220 server.example.com ESMTP Postfix

3.2.2 - 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

3.2.3 - 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
...

3.2.4 - 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
.

3.2.5 - QUIT


QUIT

4 - Command

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 (smtpd_forbidden_commands)

  • CONNECT,
  • GET,
  • POST

Login:

  • AUTH LOGIN (then username password)

5 - Documentation / Reference


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap