X-Git-Url: http://git.jankratochvil.net/?p=PerlMail.git;a=blobdiff_plain;f=perlmail-sendmail;h=f819bccb40b2d599ae2e38766fcaa0aa8a844616;hp=64cf70366463b033ef265d5672d440b69d655503;hb=9d03569bd26dfb0f54f21063445fc9d28ed1c4d3;hpb=ba95562b1683631fd058e10bb8205dfecd3e3fe8 diff --git a/perlmail-sendmail b/perlmail-sendmail index 64cf703..f819bcc 100755 --- a/perlmail-sendmail +++ b/perlmail-sendmail @@ -7,70 +7,16 @@ $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; }; use strict; use warnings; +use File::Basename; +BEGIN { + use lib $ENV{"PERLMAIL_BASEDIR"} || File::Basename::dirname($0); + use PerlMail::Config; + } + require Getopt::Long; use POSIX qw(WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG); require MIME::Head; # inherits Mail::Header require Mail::Address; -require File::Basename; -require Mail::Alias; - -my $sendmail_orig=(-x ($_="/usr/sbin/sendmail-orig") ? $_ : "/usr/sbin/sendmail"); -my $HOME="/home/short"; -# Mail-Alias-1.12 defaults to "/etc/mail/aliases" which does not exist on RedHat sendmail-8.12.5-7 -# Mail-Alias-1.12 will clutter $_ ! -my @addr_addon=(Mail::Alias->new("/etc/aliases")->exists("sentout") ? ("sentout") : ()); -my $opt_F; -my $is_pgp; -sub FromAddress -{ -my($rcpt,$iserror)=@_; - - my $phrase=(defined $opt_F ? $opt_F : "Jan Kratochvil"); - { - last if !$is_pgp; - last if $iserror; - local *F; - local $_; - my $filename="$HOME/.gnupg/options"; - open F,$filename or do { warn "Open \"$filename\": $!"; last; }; - local $/="\n"; - my @keys=map((/^\s*default-key\s+(\S+)\s*$/),); - @keys==1 or do { warn "Found ".scalar(@keys)." 'default-key's in your \"$filename\", ignoring"; last; }; - close F or warn "Close \"$filename\": $!"; - my $default_key=$keys[0]; - $default_key=~/^[[:xdigit:]]{8}$/ or do { warn "Invalid 'default-key', ignoring: $default_key"; last; }; - return Mail::Address->new( - $phrase, - 'pgp-'.uc($default_key).'@jankratochvil.net', - ); - } - # !$is_pgp or fallback - return Mail::Address->new( - $phrase, - (!$iserror ? 'rcpt' : 'rcpterr') - .'-' - .(defined($rcpt->user()) ? $rcpt->user() : "NOUSER") - .".AT." - .(defined($rcpt->host()) ? $rcpt->host() : "LOCAL") - .'@jankratochvil.net', - ); -} - -# RedHat sendmail-8.9.3-20/src/conf.c/HdrInfo[]/\Q/* destination fields */\E -# FIXME: Recognize "Resent-$_" headers for -t but when we are in 'resent' mode? -my @h_rcpt=( # case in-sensitive! - "To", - "Cc", - "Bcc", - "Apparently-To", - ); - -# ordering matters; first header found is substituted -# last header is subsituted if no one is found -my @h_from=( - "Resent-From", - "From", - ); # FIXME: modularized unification with 'perlmail-accept' @@ -170,7 +116,7 @@ my $opt_Q; my $opt_q; my $opt_t; our $opt_f; -#my $opt_F; # declared before &FromAddress already +our $opt_F; # from PerlMail::Config; my $opt_perlmail_dry_run; my @ARGV_save=@ARGV; # for non-bm mode die if !Getopt::Long::GetOptions( @@ -247,6 +193,7 @@ 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#; }