]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/Mail.pm
Add an rfc822_date function to Debbugs::Mail
[debbugs.git] / Debbugs / Mail.pm
index d915c678e4e5caf53083fcd9b12afb9243ad7cd8..64cd6f2dd0ec332fb4a75cc3850482d2a45208a1 100644 (file)
@@ -1,4 +1,9 @@
-# $Id: Mail.pm,v 1.1 2005/08/17 21:46:16 don Exp $
+# This module is part of debbugs, and is released
+# under the terms of the GPL version 2, or any later
+# version at your option.
+# See the file README and COPYING for more information.
+#
+# Copyright 2004-7 by Don Armstrong <don@donarmstrong.com>.
 
 package Debbugs::Mail;
 
@@ -37,7 +42,7 @@ use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT);
 use base qw(Exporter);
 
 use IPC::Open3;
-use POSIX ":sys_wait_h";
+use POSIX ":sys_wait_h strftime";
 use Time::HiRes qw(usleep);
 use Mail::Address ();
 use Debbugs::MIME qw(encode_rfc1522);
@@ -49,7 +54,7 @@ BEGIN{
      $DEBUG = 0 unless defined $DEBUG;
 
      @EXPORT = ();
-     @EXPORT_OK = qw(send_mail_message get_addresses encode_headers);
+     @EXPORT_OK = qw(send_mail_message get_addresses encode_headers rfc822_date);
      $EXPORT_TAGS{all} = [@EXPORT_OK];
 
 }
@@ -130,6 +135,9 @@ sub send_mail_message{
      my @recipients;
      @recipients = @{$param{recipients}} if defined $param{recipients} and
          ref($param{recipients}) eq 'ARRAY';
+     my %recipients;
+     @recipients{@recipients} = (1) x @recipients;
+     @recipients = keys %recipients;
      # If there are no recipients, use -t to parse the message
      if (@recipients == 0) {
          $param{parse_for_recipients} = 1 unless exists $param{parse_for_recipients};
@@ -183,6 +191,17 @@ sub encode_headers{
      return $header . qq(\n\n). $body;
 }
 
+=head2 rfc822_date
+
+     rfc822_date
+
+Return the current date in RFC822 format in the UTC timezone
+
+=cut
+
+sub rfc822_date{
+     return scalar strftime "%a, %d %h %Y %T +0000", gmtime;
+}
 
 =head1 PRIVATE FUNCTIONS