Friday, March 13, 2015

Simple shell based smtp client... really simple..

I first found email as part of cygwin.   This is a quick and simple tool for sending email.  I use it to send status messages and attaching scheduled reports from shell scripts.  it just works.  no fuss, no local mta setup.

I've installed, it into Ubuntu server, and Raspbian and had it work, as well as using it regularly in Cygwin.  The man page is really thorough.  There are optional config files, but I typically specify everything on the command call, just personal preference.

My quick script for installing dean jone's email program, based on his site. (ok, i added a line to get the parts to compile, otherwise it's his commands to pull and build.  Being that this blog serves as my personal annotated bookmarks, I hope he doesn't mind)


In my scripts, I put the following at the top

email_from_address=some@email.address
email_from_name="someones name"
email_server=address or ip
email_port=a port
email_recipients=someoneelse@email.address,different@server.elsewhere

and then where I want to send email,

echo "
 message here 

white space is sent so layout your message as you want it
to look

great!
" | email -n $email_from_name -f $email_from_address -s "subject" -r
$email_server -p $email_port $email_recipients



that's it..

If bcc is needed, do --bcc before the final recipients list and and a list of recipients

No comments:

Post a Comment