Added a date stamp to outgoing mail to maintain compliance with the RFC2822 specification.

This commit is contained in:
JT Smith 2003-04-13 03:46:21 +00:00
parent cdfdd07219
commit 52c551bb83
2 changed files with 25 additions and 5 deletions

View file

@ -175,6 +175,7 @@ A string representing the output format for the date. Defaults to '%z %Z'. You c
%% = % (percent) symbol. %% = % (percent) symbol.
%c = The calendar month name. %c = The calendar month name.
%C = The calendar month name abbreviated to 3 characters and represented in English.
%d = A two digit day. %d = A two digit day.
%D = A variable digit day. %D = A variable digit day.
%h = A two digit hour (on a 12 hour clock). %h = A two digit hour (on a 12 hour clock).
@ -184,10 +185,13 @@ A string representing the output format for the date. Defaults to '%z %Z'. You c
%m = A two digit month. %m = A two digit month.
%M = A variable digit month. %M = A variable digit month.
%n = A two digit minute. %n = A two digit minute.
%o = Offset from GMT represented as an integer.
%O = Offset from GMT represented in four digit form with a sign. Example: -0600
%p = A lower-case am/pm. %p = A lower-case am/pm.
%P = An upper-case AM/PM. %P = An upper-case AM/PM.
%s = A two digit second. %s = A two digit second.
%w = The name of the week. %w = Day of the week.
%W = Day of the week abbreviated to 3 characters and represented in English.
%y = A four digit year. %y = A four digit year.
%Y = A two digit year. %Y = A two digit year.
%z = The current user's date format preference. %z = The current user's date format preference.
@ -205,6 +209,12 @@ sub epochToHuman {
$temp = $temp+$offset; $temp = $temp+$offset;
my ($year,$month,$day,$hour,$min,$sec) = Date::Calc::Time_to_Date($temp); my ($year,$month,$day,$hour,$min,$sec) = Date::Calc::Time_to_Date($temp);
$output = $_[1] || "%z %Z"; $output = $_[1] || "%z %Z";
#---GMT Offsets
$temp = $session{user}{timeOffset}*100;
$temp = sprintf('%+05d',$temp);
$output =~ s/\%O/$temp/g;
$temp = $session{user}{timeOffset}+0;
$output =~ s/\%o/$temp/g;
#---dealing with percent symbol #---dealing with percent symbol
$output =~ s/\%\%/\%/g; $output =~ s/\%\%/\%/g;
#---date format preference #---date format preference
@ -222,16 +232,24 @@ sub epochToHuman {
$output =~ s/\%m/$value/g; $output =~ s/\%m/$value/g;
$output =~ s/\%M/$month/g; $output =~ s/\%M/$month/g;
if ($output =~ /\%c/) { if ($output =~ /\%c/) {
my $monthName = getMonthName($month); $temp = getMonthName($month);
$output =~ s/\%c/$monthName/g; $output =~ s/\%c/$temp/g;
}
if ($output =~ /\%C/) {
$temp = substr(Date::Calc::Month_to_Text($month),0,3);
$output =~ s/\%C/$temp/g;
} }
#---day stuff #---day stuff
$value = sprintf("%02d",$day); $value = sprintf("%02d",$day);
$output =~ s/\%d/$value/g; $output =~ s/\%d/$value/g;
$output =~ s/\%D/$day/g; $output =~ s/\%D/$day/g;
if ($output =~ /\%w/) { if ($output =~ /\%w/) {
my $dayName = getDayName(Date::Calc::Day_of_Week($year,$month,$day)); $temp = getDayName(Date::Calc::Day_of_Week($year,$month,$day));
$output =~ s/\%w/$dayName/g; $output =~ s/\%w/$temp/g;
}
if ($output =~ /%W/) {
$temp = Date::Calc::Day_of_Week_Abbreviation(Date::Calc::Day_of_Week($year,$month,$day));
$output =~ s/\%W/$temp/g;
} }
#---hour stuff #---hour stuff
$hour12 = $hour; $hour12 = $hour;

View file

@ -16,6 +16,7 @@ package WebGUI::Mail;
use Net::SMTP; use Net::SMTP;
use strict; use strict;
use WebGUI::DateTime;
use WebGUI::ErrorHandler; use WebGUI::ErrorHandler;
use WebGUI::Macro; use WebGUI::Macro;
use WebGUI::Session; use WebGUI::Session;
@ -86,6 +87,7 @@ sub send {
$message .= "CC: $_[3]\n" if ($_[3]); $message .= "CC: $_[3]\n" if ($_[3]);
$message .= "BCC: $_[5]\n" if ($_[5]); $message .= "BCC: $_[5]\n" if ($_[5]);
$message .= "Subject: ".$_[1]."\n"; $message .= "Subject: ".$_[1]."\n";
$message .= "Date: ".WebGUI::DateTime::epochToHuman("","%W, %d %C %y %j:%n:%s %O")."\n";
$message .= "\n"; $message .= "\n";
$message = WebGUI::Macro::process($message); $message = WebGUI::Macro::process($message);
#body #body