rcpt-USER.AT.HOST@jankratochvil.net for lists.
[PerlMail.git] / perlmail-sendmail
index 6a4e31e..276e3dd 100755 (executable)
@@ -1,6 +1,22 @@
 #! /usr/bin/perl
-#
-# $Id$
+# 
+#      $Id$
+# Copyright (C) 2002-2003 Jan Kratochvil <project-PerlMail@jankratochvil.net>
+# 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
 
 use vars qw($VERSION);
 $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
@@ -43,8 +59,7 @@ my $opt_b;
 my $opt_Q;
 my $opt_q;
 my $opt_t;
-our $opt_f;
-our $opt_F;    # from PerlMail::Config;
+our $opt_f;    # not exported, just for local()
 my $opt_perlmail_dry_run;
 my @ARGV_save=@ARGV;   # for non-bm mode
 die if !Getopt::Long::GetOptions(
@@ -110,7 +125,6 @@ my $from_headername;
        }
 
 # to be utilized later by &FromAddress
-our $is_pgp;   # from PerlMail::Config;
 $is_pgp=(1
                && do { local $_=$head->mime_attr("Content-Type");          $_ && ~m#^multipart/(?:signed|encrypted)$#; }
                && do { local $_=$head->mime_attr("Content-Type.protocol"); $_ && ~m#^application/pgp\b#; }
@@ -139,7 +153,11 @@ for my $rcpt (@rcpts) {
        if (defined $rcpt) {    # !defined($rcpt) if we have no recipients
                local $_;
                $opt_f=FromAddress($rcpt,1)->address() if !defined $opt_f;
-               $head->replace($from_headername,FromAddress($rcpt,0)->format()) if $from_headername;
+               if ($from_headername) {
+                       if (my $fromaddr=FromAddress($rcpt,0)->format()) {
+                               $head->replace($from_headername,$fromaddr);
+                               }
+                       }
                }
 
        1;      # drop '-bm' if present as it is default anyway