Hello,
I am trying to set up an automated mailer for testing a product to see if it looses mail. I want the perl script to email me every 30 seconds with the time (ie 10:33:45) in the subject. That way I know if mail has been lost because I will have a timestamp missing. I have a mail script I have used frequently, but when I run it, the timestamp is the same on each mail. Any help would be great
use Net::SMTP;
##################################################################
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time) ;
#print "$Hour:$Minute:$Second\n";
my $counter =0;
while ($counter <50) {
my $warningEmailMessage .="$Hour:$Minute:$Second";
my $MyToAddress = 'administrator@company.com';
my $MyFromAddress = 'timestamp@company.com';
my $MyCCAddress = 'xxtest3@company.com';
my $MyHost = "mail1";
my $MySite = "company.com";
my $smtp = Net::SMTP->new($MyHost, Hello=>$MySite);
$smtp->mail($MyFromAddress);
$smtp->to($MyToAddress);
$smtp->cc($MyCCAddress);
$smtp->data();
$smtp->datasend("To:$MyToAddress\n");
$smtp->datasend("Subject: $Hour:$Minute:$Second\n");
$smtp->datasend("\n$warningEmailMessage\n");
$smtp->dataend();
$smtp->quit;
print ("\nThe email report was sent successfully.");
sleep 30;
$counter++;
}
I am trying to set up an automated mailer for testing a product to see if it looses mail. I want the perl script to email me every 30 seconds with the time (ie 10:33:45) in the subject. That way I know if mail has been lost because I will have a timestamp missing. I have a mail script I have used frequently, but when I run it, the timestamp is the same on each mail. Any help would be great
use Net::SMTP;
##################################################################
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time) ;
#print "$Hour:$Minute:$Second\n";
my $counter =0;
while ($counter <50) {
my $warningEmailMessage .="$Hour:$Minute:$Second";
my $MyToAddress = 'administrator@company.com';
my $MyFromAddress = 'timestamp@company.com';
my $MyCCAddress = 'xxtest3@company.com';
my $MyHost = "mail1";
my $MySite = "company.com";
my $smtp = Net::SMTP->new($MyHost, Hello=>$MySite);
$smtp->mail($MyFromAddress);
$smtp->to($MyToAddress);
$smtp->cc($MyCCAddress);
$smtp->data();
$smtp->datasend("To:$MyToAddress\n");
$smtp->datasend("Subject: $Hour:$Minute:$Second\n");
$smtp->datasend("\n$warningEmailMessage\n");
$smtp->dataend();
$smtp->quit;
print ("\nThe email report was sent successfully.");
sleep 30;
$counter++;
}