A
alexbarham
I am using MIME::Lite to send out an attachment for any image that is
received within each hour. Here is what I have:
use Date::Manip;
use MIME::Lite;
use Net::SMTP;
my $current_time = localtime;
<code that reads directory here>
foreach my $file(@files){
my $lastmodtime = stat($file);
my $currenttime = localtime;
<Date::Manip code to parse dates and extract elapsed hours>
<When I first started, I used -M $file but it kept crashing with some
obscure error, I just reran it and it worked??>
So as it is now:
<@time refers to DateCalc which will return +0:0:WKD:HH:MM:SS. I want
the 4th element to grab the elapsed hours)
if ($time[4] < 0.5){
send_message($file);
}
sub send_message{
my $file_name = shift;
my $msg = MIME:Lite->new(
From=>'(e-mail address removed)',
To=>'(e-mail address removed)',
Subject=>$file_name,
Type=>'image/jpeg',
Encoding=>'base64',
Path=>"/root/PERL/test_scripts/$file_name"
(;
MIME::Lite->send('smtp','smtp.myisp.com',Timeout=>60);
$msg->send;
}
The problem I have that only the last email is sent. The first emails
don't get sent. Any ideas as to what could cause this? I am wondering
if I need to rename the MIME::Lite object through each loop iteration
($msg1, $msg2, $msg3 etc...)
Thanks in advance for everyone's help
received within each hour. Here is what I have:
use Date::Manip;
use MIME::Lite;
use Net::SMTP;
my $current_time = localtime;
<code that reads directory here>
foreach my $file(@files){
my $lastmodtime = stat($file);
my $currenttime = localtime;
<Date::Manip code to parse dates and extract elapsed hours>
<When I first started, I used -M $file but it kept crashing with some
obscure error, I just reran it and it worked??>
So as it is now:
<@time refers to DateCalc which will return +0:0:WKD:HH:MM:SS. I want
the 4th element to grab the elapsed hours)
if ($time[4] < 0.5){
send_message($file);
}
sub send_message{
my $file_name = shift;
my $msg = MIME:Lite->new(
From=>'(e-mail address removed)',
To=>'(e-mail address removed)',
Subject=>$file_name,
Type=>'image/jpeg',
Encoding=>'base64',
Path=>"/root/PERL/test_scripts/$file_name"
(;
MIME::Lite->send('smtp','smtp.myisp.com',Timeout=>60);
$msg->send;
}
The problem I have that only the last email is sent. The first emails
don't get sent. Any ideas as to what could cause this? I am wondering
if I need to rename the MIME::Lite object through each loop iteration
($msg1, $msg2, $msg3 etc...)
Thanks in advance for everyone's help