Sending mail from shell

this post is about going back to basics, how to send an email from shell, even though that’s basic however still its one of the things you need once a while and when you do usually you have to google it cause you forgot all about it, so here it goes.

basically sending mail from shell is easy, you need one of the following packages to do it:

  • mail
  • mailx
  • mutt
  • sendmail
All packages build on top of mail, however they provide simpler interfaces that can be easily integrated into scripts, basically mailx and mail are really similar, sending an email using either only requires the following
echo “email body”| mailx -s “subject” to@domain.com
sendmail provides more functionality with an easier way to set the from address (to avoid being caught in the recipients proxy) by modifying its config file, also you can easily send files using it.
sendmail -v user@domainname < test.mail
Even simpler if you want a simpler way to use a from email address use the following command
 echo “Please check http://twittermarketeer.info&#8221; |mailx -s “hello” to@gmail.com — -r “from@gmail.com”
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s