We can easily send/receive mails from Linux command line: this is really useful when you have to test your mail server or to send messages from shell scripts.
Install the package bsd-mailx or mailutils (I use bsd-mailx, but don't ask me why) with
apt-get install bsd-mailx
apt-get install mailutils
Useful parameters for the mail command are:
mail -s "Hello World" firstname.lastname@example.org
sends a mail to email@example.com with subject “Hello World”, while
mail -s "Hello World" -c firstname.lastname@example.org email@example.com
sends also a copy of the mail to a second mailbox.
It is possible to specify multiple recipients by joining them with a comma.
mail -s "Hello World" firstname.lastname@example.org,email@example.com
To set the body of the message, you can pipe it to the mail command
echo "Message body here" | mail -s "Subject here" firstname.lastname@example.org
or redirect the content of a file
mail -s "Subject here" email@example.com < /home/user/mail-body.txt
You can also use the output of other tool. To send the system memory usage to the sysadmin, you could try something like
free -h | mail -s "System memory usage" firstname.lastname@example.org
GTUBE is the Generic Test for Unsolicited Bulk Email. If your spam filter supports it, the GTUBE provides a test by which you can verify that the filter is installed correctly and is detecting incoming spam.
You can send yourself a test mail containing the following string of characters (in upper case and with no white spaces and line breaks):
You should send this test mail from an account outside of your network to avoid domain bypass rules.
echo "XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X" | mail -s "GTUBE test mail" email@example.com