Email Tutorials - Herong's Tutorial Examples - v1.04, by Herong Yang
Test Postfix Server with "telnet" Client
This section provides a tutorial example on how to test Postfix server with the 'telnet' client command to send a SMTP request to the server on port 25. Postfix will delivery emails to the '~/Maildir' sub-directory for each user.
One way to test the Postfix server is to use the "telnet" client command. All we need is the IP address of the server and the SMTP port number, which is defaulted to 25. Here is how I did it.
1. Run the following "telnet" session on my CentOS computer where Postfix server is running.
herong$ telnet localhost 25 Trying ::1... Connected to localhost. Escape character is '^]'. 220 mail.herongyang.com ESMTP Postfix ehlo localhost 250-mail.herongyang.com ... 250 SMTPUTF8 mail from: herong 250 2.1.0 Ok rcpt to: herong 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF> Hello world! . 250 2.0.0 Ok: queued as 5EABD266002B quit 221 2.0.0 Bye Connection closed by foreign host.
2. Make sure that the email is delivered to herong's email directory. The output shows Postfix handles local SMTP requests correctly. And it delivers emails to local email addresses correctly. Note that this email file will be moved the "cur" sub-directory in few minutes.
herong$ cd /home/herong/Maildir/new/ herong$ ls 1605266421.Vfd02I203e0c2M847016.localhost.localdomain herong$ more 1605266421.Vfd02I203e0c2M847016.localhost.localdomain Return-Path: <herong@example.com> X-Original-To: herong Delivered-To: herong@example.com Received: from localhost (localhost [IPv6:::1]) by mail.herongyang.com (Postfix) with ESMTP id 5EABD266002B for <herong>; 15 Nov 2023 06:19:34 -0500 (EST) Message-Id: <20231113111946.5EABD266002B@mail.herongyang.com> Date: 15 Nov 2023 06:19:34 -0500 (EST) From: herong@example.com Hello world!
3. Open firewall to handle remote SMTP requests on port 25.
herong$ sudo firewall-cmd --zone=public --add-service=smtp herong$ sudo firewall-cmd --runtime-to-permanent
4. Run the following "telnet" session on my macOS computer which is connected to the CentOS computer.
herong$ telnet 192.168.1.100 25 Trying 192.168.1.100... Connected to 192.168.1.100 Escape character is '^]'. 220 mail.herongyang.com ESMTP Postfix ehlo 192.168.1.11 250-mail.herongyang.com ... 250 SMTPUTF8 mail from: herong 250 2.1.0 Ok rcpt to: herong 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF> Hello again world! . 250 2.0.0 Ok: queued as D86E9266002D quit 221 2.0.0 Bye Connection closed by foreign host.
5. Check /home/herong/Maildir on the Postfix server to ensure the email is delivered correctly.
Ok. Both tests passed. I can inform others on my local network that my SMTP service is ready for email boxes under my domain name herongyang.com. They can use SMTP client tools to send emails to anyone who has a user account on my CentOS computer using email addresses in the format of <username>@herongyang.com.
As a reference, here a list of commonly used SMTP commands. All commands are case insensitive.
Table of Contents
►Postfix - Mail Transport Agent (MTA)
Install and Configure Postfix on CentOS
►Test Postfix Server with "telnet" Client
SMTP Submission Service on Port 587 in Postfix
Archive Emails using "always_bcc" Setting in Postfix
Move /var/spool/postfix to New Location
"postconf" Command to Manage Postfix Configuration
Turn on Postfix Server Logging for Troubleshooting
SSL/TLS Secure Connections with Postfix Server
Dovecot - IMAP and POP3 Server
SSL/TLS Secure Connections with Dovecot Server
Email Client Tools - Mail User Agents (MUA)
Mozilla Thunderbird - Mail User Agents (MUA)
PHPMailer - PHP Package for Sending Emails