Sunday, June 22, 2008

Linux sendemail script

Homepage

Install

mkdir /myth/bin
cd /myth/bin
tar -zxvf sendEmail-Vx.xx.tar.gz
ln -s /myth/bin/sendEmail-Vx.xx/sendEmail /usr/local/bin/sendemail
sendemail -f mythtv@mythtv -t toaddress -u "Subject Line" -m "Body of the message" -a FileNameToAttach

From a knoppmyth forum post:

I've got my Myth box setup to send me a daily email listing of each days shows that it has recorded. I'm leveraging 'sendEmail.pl” which is available here http://caspian.dotconf.net/menu/Software/SendEmail/

Here is my shell script that pulls the data from Mysql and pushes the email. It doesn't require a local SMTP server or any other whacky dodads. I just sends the mail to my ISP mailbox. Easy as pie.

#! /bin/bash
echo "" > /usr/src/sendemail/today.txt
mysql -H mythconverg < /usr/src/sendemail/dumptoday.sql >> /usr/src/sendemail/today.txt
echo "

See the full listing of recorded programs" >> /usr/src/sendemail/today.txt
echo "" >> /usr/src/sendemail/today.txt
perl /usr/src/sendemail/sendEmail.pl -f "Our DVR " -t insertTOemailaddresshere -u "Today's Shows" -s insertISPserveraddresshere -xu insertISPauthcredentialshere(opt) -xp insertISPpasswordhere(opt) -o message-file=/usr/src/sendemail/today.txt

The dumptoday.sql looks like this:

select title,starttime,description from recordedprogram where date_sub(curdate(),interval 0 day) <= starttime;

It's a quick and dirty solution so if anyone can improve on it I'd be very happy to reap the benefits.

No comments: