I'm writing a Perl script to run on a Linux box which needs to send emails. I'm using Net::SMTP to send the mail, with a subroutine adding the headers etc. being called from the body of the script.
I'm struggling to work out how to generate an RFC2183 date for use in the MIME headers - the top half of the SMTP subroutine is attached.
sub send_mail # send SMTP mail
my ($from, $to_addr, $subject, $body, $msg, $date);
$from = shift;
$to_addr = shift;
$subject = shift;
$body = shift;
$msg = "MIME-Version: 1.0\n"
. "From: $from\n"
. "To: " . ( ref($to_addr) ? join(';', @$to_addr) : $to_addr ) . "\n"
. "Date: " . date_r() . "\n"
. "Subject: $subject\n\n" # Double \n
The format of the time string that I need for the MIME header is: Wed, 12 Feb 1997 16:29:51 -0500
I would like to know what commands will generate this format of date, and which modules I need to include to use them.