Centos – Mailx Examples

From

echo 'Rsync on BlaBlaBla Done' | mail -s 'Rsync on BlaBlaBla Done' -r "BackUp"  [email protected]_domain.com

Multiple recipients

echo "This is message body" | mail -s "This is Subject "[email protected],[email protected]

CC and BCC

echo "This is message body" | mail -s "This is Subject" -c [email protected] [email protected]

Take message from a file
mail -s “This is Subject” [email protected] < /path/to/file Specify “Reply-To” address

# replyto email
$ echo "This is message" | mail -s "Testing replyto" -S replyto="[email protected]" [email protected]

# replyto email with a name
$ echo "This is message" | mail -s "Testing replyto" -S replyto="Mark" [email protected]

Attachments

echo "This is message body" | mail -s "This is Subject" -r "Harry" -a /path/to/file [email protected]

Use external SMTP server

echo "This is the message body and contains the message" | mailx -v -r "[email protected]" -s "This is the subject" -S smtp="mail.example.com:587" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="[email protected]" -S smtp-auth-password="abc123" -S ssl-verify=ignore [email protected]

Trouble Shooting

sudo netstat -ltnp | grep 25