Send mail from command line

Sending mail directly from a Linux server can often be handy. Here is how I do it

Send mail

cat "Test" | mail -s "Test subject" someone@someplace.com

This will send a mail with the message “Test” and subject line “Test subejct” to email adress: someone@someplace.com

Send attachments

mutt -s "Attachment subject" -a attachment.jpg someone@someplace.com

This will open up your favorite editor so you can create a mail message to your attachment. After you save and exit the editor you just press ‘y’ to send the message with the attachment (you will be inside Mutt then)

Tested on RHEL 3

Comments are closed.