HostOnNet Blog

Sending mail from command line

Spam Filter Solutions

Check Mail Server

Mail using sendmail command

To debug email servers, you may need to quickly send a test email from command line, then check the logs. You can use mail command to send mail. But you need to fill multiple fields.

On Ubuntu/Debian, you need to install mailutils package

apt install -y mailutils

On CentOS

yum install mailx

Here is one line command to send email from terminal.

echo "This email body" | mail -s "test email from `hostname`"

You can use -v option to verify/debug

echo "This email body" | mail -v -s "test email from `hostname`"


Set from address for mail command

echo "Test mail" | mail -s "test mail" -a "From:"

Mail Server Solutions

Related Posts

Posted in Linux