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.

Niklas Tech Blog
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.