HostOnNet Blog

Sending mail from command line

Looking for Linux Server Admin or WordPress Expert? We can help.

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`" [email protected]

You can use -v option to verify/debug

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

mail-cmd

Set from address for mail command

echo "Test mail" | mail -s "test mail" -a "From: [email protected]" [email protected]

Mail Server Solutions

Related Posts

Posted in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.