Test TCP Port 25 (smtp) access with telnet
In this article we show you how to use telnet to test the access to a mail server on TCP port 25.
SMTP Protocol Basics
SMTP is a plain text protocol.[1][2] This makes it easy to simulate a mail client with the telnet command to check the access to port 25.
The following steps are required on a Linux command line:
- Execute
telnet SERVERNAME 25
. This connects telnet to port 25 on the server with the name SERVERNAME. The name or IP address of the server for a domain can be determined bydig DOMAIN -t MX
. If there is no own MX record for a domain, the corresponding A-record must be used. - If the TCP connection can be established, telnet responds with the message
Connected to SERVERNAME.
andEscape character is' ^]'.
. - Now you can send an e-mail via SMTP protocol. The best way to do this is to use a recipient address for which the connected mail server is responsible.
EHLO test.example.com
MAIL FROM:<SENDERADDRESS>
RCPT TO:<RECIPIENTADDRESS>
DATA
Subject: Testmessage
- (Blank line, press Enter again)
This is a test.
- (Blank line, press Enter again)
.
QUIT
Example
In the following example, an e-mail is sent to an e-mail address. In the example below, the domain example.com is used for documentation, please replace it with your mail server:[3]
[user@fedora9 user]$ telnet mail.example.com 25 Trying 192.0.2.10... Connected to mail.example.com. Escape character is '^]'. 220 mail.example.com ESMTP Postfix (Debian/GNU) EHLO test.example.com 250-mail.example.com 250-PIPELINING 250-SIZE 30720000 250-VRFY 250-ETRN 250-STARTTLS 250-AUTH LOGIN DIGEST-MD5 PLAIN CRAM-MD5 250-AUTH=LOGIN DIGEST-MD5 PLAIN CRAM-MD5 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN MAIL FROM:<test@example.com> 250 2.1.0 Ok RCPT TO:<user@example.com> 250 2.1.5 Ok DATA 354 End data with <CR><LF>.<CR><LF> Subject: Testmessage This is a test. . 250 2.0.0 Ok: queued as 83398728027 QUIT 221 2.0.0 Bye Connection closed by foreign host. [user@fedora9 user]$
References
- ↑ Simple Mail Transfer Protocol (en.wikipedia.org)
- ↑ RFC 5321 - Simple Mail Transfer Protocol (ietf.org)
- ↑ Example.com (en.wikipedia.org)
Author: Thomas Niedermeier Thomas Niedermeier working in the product management team at Thomas-Krenn, completed his bachelor's degree in business informatics at the Deggendorf University of Applied Sciences. Since 2013 Thomas is employed at Thomas-Krenn and takes care of OPNsense firewalls, the Thomas-Krenn-Wiki and firmware security updates.
|