amazon simple email service - search for a kitteh!
2011-02 Free tier*
If you have an Amazon EC2 instance running (e.g. EC2 Linux Micro Instance in Free Tier = centos!) (And you're not running over the GET/POST upload/download free tier bandwidths)
Sign up for SES (then receive a verification email for your Amazon AWS Account) Account Security Credentials (for AWS access identifiers) create a file aws-credentials (Amazon's sample below)
AWSAccessKeyId=022QF06E7MXBSH9DHM AWSSecretKey=kWcrlUX5JEDGM/LtmEENI/aVmYvHNif5zB+d9+
Download the example perl scripts via: http://aws.amazon.com/code/Amazon-SES wget http://aws-catalog-download-files.s3.amazonaws.com/AmazonSES-2011-02-02.zip
unzip AmazonSES-2011-02-02.zip chmod +x /home/ec2-user/*.pl
/home/ec2-user/bin/ses-verify-email-address.pl -k aws-credentials -v youreemail@domain.com
"Can't locate XML/LibXML.pm in @INC (@INC contains: /usr/local/lib64/perl5
/usr/local/share/perl5 /usr/local/share/perl5 /usr/lib64/perl5 /usr/share/perl5
/usr/share/perl5 /usr/lib64/perl5 /usr/share/perl5
/usr/local/lib64/perl5/site_perl/5.10.0/x86_64-linux-thread-multi
/usr/local/lib/perl5/site_perl/5.10.0
/usr/lib64/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl
/usr/lib/perl5/site_perl .) at ./ses-verify-email-address.pl line 26.
BEGIN failed--compilation aborted at ./ses-verify-email-address.pl line 26."
THANKS AMAZON! Using their preconfigured Instance means they don't have the Perl libxml package.
sudo yum install perl-XML-LibXML perl-digest-SHA
sudo yum provides */SHA.pm (tells me what other packages I might have missed...
sudo yum search perl-Digest-SHA
sudo yum search perl-Digest-SHA
( What a difference a D versus d makes!) ( sudo yum perl-libxml-perl libxml2-devel perl-IO-Socket-SSL libxslt-devel ?) (debian sudo apt-get install libio-socket-ssl-perl libxml-libxml-perl) tail /var/log/maillog for troubleshooting sendmail...
/home/ec2-user/bin/ses-verify-email-address.pl -k aws-credentials -v youreemail@domain.com
use the email account you gave above for verification and click on the link... You have successfully verified an email address with Amazon Simple Email Service.
~/amazonses/bin/ses-send-email.pl -k ~/amazonses/bin/aws-credentials -s "Test AWS" -f fromemail@domain.com toemail@domain.com < ~/kittysearch/result.txt
-k = authentication credentials -s = subject , -f = from (must be a verified address)
/bin/bash
wget -O ~/kittysearch/page1.htm 'http://adopt.hssv.org/search/searchResults.asp?task=search&searchid=&advanced=&s=adoption&animalType=2%2C15&statusID=3&state=®ionID=&submitbtn=Find+Animals'
wget -O ~/kittysearch/page2.htm 'http://adopt.hssv.org/search/searchResults.asp?tpage=2&task=search&searchid=&advanced=&s=&animalType=2,15&statusID=3&state=®ionID=&submitbtn=Find+Animals'
wget -O ~/kittysearch/page3.htm 'http://adopt.hssv.org/search/searchResults.asp?tpage=3&task=search&searchid=&advanced=&s=&animalType=2,15&statusID=3&state=®ionID=&submitbtn=Find+Animals'
grep -i "bandit" ~/kittysearch/page1.htm ~/kittysearch/page2.htm ~/kittysearch/page3.htm > ~/kittysearch/result.txt
if [ -s ~/kittysearch/result.txt ] then
# must move to the directory to use the SES.pm cd ~/amazonses/bin
./ses-send-email.pl -k ~/amazonses/bin/aws-credentials -s "Test AWS" -f myemail@domain.com myemail@domain.com,secondrecipient@domain.com < ~/kittysearch/result.txt
fi
http://docs.amazonwebservices.com/ses/latest/DeveloperGuide/ for full details about email.pl
crontab -e (i key to enter input in vi) 55 * * /home/ec2-user/kittysearch/kittysearch.sh (escape key gets : then x to save and quit)
Running the script from a different directory or CRON gets the error: "Can't locate SES.pm in @INC"
cp /home/ec2-user/amazonses/bin/SES.pm /home/ec2-user/kittysearch
FIXED!
Consider using an IF statement in the bash script to only send an email if the kitteh is found...
*You can send 2,000 messages for free each day when you call Amazon SES from an Amazon EC2 instance directly or through AWS Elastic Beanstalk. (Note bandwidth charges may still apply)