Thursday, February 08, 2007

Scripting e-mail sending

[Technical]

For a long time, I was trying to find a way of sending e-mail from the command line, so that I could script/cron it. The alternative available was to write a Perl script to do the same, but I was too lazy to do so.
After trying hard and failing to understand sendmail, and not even finding a proper copy installed anywhere on the IISc LAN, I tried acheiving the result with Pine and failed too.

Mutt proved to be the saviour.

Steps (- substitute all italicized content appropriately):
1) Create a file henceforth called in with the following content:
To: bob@domain.com
Subject: Test message
Dear Alice,
...
Bob

You can add other fields such as BCC: etc. as well. Only the To: field is compulsory, the subject and body are not.

2) Run:
mutt -a attachmentfilename1 -a attachmentfilename2 -H in </dev/null

That's it.

No comments: