Perl send email script

#This script requires your own Email sever as this does not onclude Auhtnetication

#*******Email the Files generated***************
sub sendmail()
{
my $sender = new Mail::Sender{
smtp=>’mail.sonicwall.com’,
from=>’isutaria@sonicwall.com’,
on_errors=>undef,
}
or die “Cant Create\n”;

$sender->OpenMultipart({
to=>’isutaria@sonicwall.com’,
Subject=>’Auto generated Message for checking the Up time of the firewall for TestBeds UK,Canada,Brazil ‘,
})
or die “Cant open\n”;
#Check to see if files exist then attach else go to next file
if (-e “$day:$month:$yr-Canada.txt”)
{
$sender->Attach({
description=>’TestBed Status Files’,
dispositon=>’attachement; filename=”$day:$month:$yr-Canada.txt”; type=”txt”‘,
file=>”$day:$month:$yr-Canada.txt”,
});
}
if(-e “$day:$month:$yr-UK.txt”)
{
$sender->Attach({
description=>’TestBed Status Files’,
dispositon=>’attachement; filename=”$day:$month:$yr-UK.txt”; type=”txt”‘,
file=>”$day:$month:$yr-UK.txt”,
});
}
if(-e “$day:$month:$yr-brazil.txt”)
{
$sender->Attach({
description=>’TestBed Status Files’,
dispositon=>’attachement; filename=”$day:$month:$yr-brazil.txt”; type=”txt”‘,
file=>”$day:$month:$yr-brazil.txt”,
});
}
if(-e “$day:$month:$yr-Japan.txt”)
{
$sender->Attach({
description=>’TestBed Status Files’,
dispositon=>’attachement; filename=”$day:$month:$yr-Japan.txt”; type=”txt”‘,
file=>”$day:$month:$yr-Japan.txt”,
});
}
$sender->Close
or die “No close”;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s