use warnings;
use File::Basename;
+use File::Spec::Link;
BEGIN {
- use lib $ENV{"PERLMAIL_BASEDIR"} || File::Basename::dirname($0);
- use PerlMail::Config;
- use PerlMail::Lib;
+ eval 'use lib $ENV{"PERLMAIL_BASEDIR"} || File::Basename::dirname(File::Spec::Link->resolve($0));';
}
+use PerlMail::Config;
+use PerlMail::Lib;
require Getopt::Long;
use POSIX qw(WIFEXITED WEXITSTATUS WIFSIGNALED WTERMSIG WIFSTOPPED WSTOPSIG);
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(
}
# 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#; }
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