#!/usr/bin/perl -w # Modules Needed: # apt-get install libssl-dev # perl -MCPAN -e shell # install Net::SSLeay # install IO::Socket::SSL # install Authen::SASL # install Net::SMTP::SSL use Net::SMTP::SSL; sub send_mail { my $to = $_[0]; my $subject = $_[1]; my $body = $_[2]; open(MYINPUTFILE, "<$ARGV[$0]"); # open for input my(@lines) = ; # read file into list my($line); foreach $line (@lines) # loop thru list { $body = $body."$line"; # print in sort order } close(MYINPUTFILE); unlink($ARGV[$0]); my $from = 'USER@gmail.com'; my $password = 'PASSWORD'; my $smtp; if (not $smtp = Net::SMTP::SSL->new('smtp.gmail.com', Port => 465, Debug => 1)) { die "Could not connect to server\n"; } $smtp->auth($from, $password) || die "Authentication failed!\n"; $smtp->mail($from . "\n"); my @recepients = split(/,/, $to); foreach my $recp (@recepients) { $smtp->to($recp . "\n"); } $smtp->data(); $smtp->datasend("From: " . $from . "\n"); $smtp->datasend("To: " . $to . "\n"); $smtp->datasend("Subject: " . $subject . "\n"); $smtp->datasend("\n"); $smtp->datasend($body . "\n"); $smtp->dataend(); $smtp->quit; } # Send away! &send_mail('TO@DOMAIN.COM', 'SMS');