monraga
12-18-2007, 12:13 AM
I need to display a timestamp in an email.
Using sendmail to send out the email. Found a perl script to "supposedly" display the date and time. Only problem, all that displays in the email is a "1" rather than the date and time. Here's what I have so far.
Function to get the date and time
#function to print date and time
sub print_date_time
{
$date = time;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime ($date);
$mon++;
if ($min < 10) { $min = "0$min"; }
if ($sec < 10) { $sec = "0$sec"; }
if ($mday < 10) { $min = "0$mday"; }
printf "<dl><dd><i>Received: %d:%s:%s %d/%s/%d</i></dl>\n", $hour, $min, $sec, $mon, $mday, $year;
}
Capture the date and time with...
$date_time = &print_date_time ();
Display the results in an email...
open ( MAIL, "| /usr/lib/sendmail -t" );
print MAIL "From: $email_address\n";
print MAIL "To: corp-support\@oqo.com \n";
print MAIL "CC: $email_address \n";
print MAIL "REPLY-TO: $email_address \n";
print MAIL "Subject: RMA Form Submission\n\n";
print MAIL "Hi $firstname $lastname, \n \n";
print MAIL "Thank you for your RMA submission. The details of your submission are as follows. \n\n";
print MAIL "$date_time";
print MAIL "\n";
I can't get it to display in the email, all that displays is a 1, help anyone? :confused:
Using sendmail to send out the email. Found a perl script to "supposedly" display the date and time. Only problem, all that displays in the email is a "1" rather than the date and time. Here's what I have so far.
Function to get the date and time
#function to print date and time
sub print_date_time
{
$date = time;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime ($date);
$mon++;
if ($min < 10) { $min = "0$min"; }
if ($sec < 10) { $sec = "0$sec"; }
if ($mday < 10) { $min = "0$mday"; }
printf "<dl><dd><i>Received: %d:%s:%s %d/%s/%d</i></dl>\n", $hour, $min, $sec, $mon, $mday, $year;
}
Capture the date and time with...
$date_time = &print_date_time ();
Display the results in an email...
open ( MAIL, "| /usr/lib/sendmail -t" );
print MAIL "From: $email_address\n";
print MAIL "To: corp-support\@oqo.com \n";
print MAIL "CC: $email_address \n";
print MAIL "REPLY-TO: $email_address \n";
print MAIL "Subject: RMA Form Submission\n\n";
print MAIL "Hi $firstname $lastname, \n \n";
print MAIL "Thank you for your RMA submission. The details of your submission are as follows. \n\n";
print MAIL "$date_time";
print MAIL "\n";
I can't get it to display in the email, all that displays is a 1, help anyone? :confused: