Testing SMTP mail sending: telnet, PowerShell and mailx
Install postfix and mailx on CentOS 8 and test an SMTP server with telnet, nc, PowerShell or mail.
How to set up command-line mail sending on CentOS 8 and test an SMTP server with telnet, PowerShell or mail.
Install mailx and postfix (CentOS 8)
sudo yum install mailx postfix
sudo service postfix restart
If sending fails because the pickup pipe is missing:
sudo yum install postfix -y
sudo yum install mailx -y
sudo mkfifo /var/spool/postfix/public/pickup
sudo systemctl restart postfix
Test SMTP with telnet
telnet mail.example.com 25
To simply check that a port is listening, nc is an alternative:
nc -zv sqlserver01 3306
-z: scan for listening daemons without sending any data.-v: verbose mode.
Manual SMTP dialogue (press Enter after each line):
HELO example.com
mail from: user@example.com
rcpt to: user@example.com
DATA
subject: test
Test message
.
Quit
PowerShell
Send-MailMessage -SmtpServer "smtp.example.com" -From 'user@example.com' -To 'user@example.com' -Subject 'test ps'
Shell (mail)
mail -s "test" "user@example.com" < /dev/null