Sending email from the command line


In developing automated scripts that scheduled to run periodically, I need to send email from inside the script to know about the script execution status and if there is any error. Here what I did to install, configure and test an email tool.


Prerequisite:
– This is tested on Windows XP, sure it works on any Linux distribution.
– You should have cygwin, install from: http://www.cygwin.com/
– It is important to be familiar with command line environment.

Run the Cygwin tool, and select “email” tool, see the picture.

After installation is complete, open the console and run:
$/usr/bin/email-config

You will get a series of questions and will have to type answers, like the SMTP server used to send email, and so on…

After finish, you can easily edit your configuration, use:
$ nano /etc/email/email.conf

You can edit your email signature file by:
$ nano /etc/email/email.sig

Now you can send email very easily:
write your email text to the file mail.txt, as example:
$echo “this is a test email” >> mail.txt
Now send the emai by:
$email -s “my email subject” myemail@mycompany.com <>

for email tool details, type:
$man email

From ahm507.blogspot.com