diff options
-rwxr-xr-x | src/m-pop | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -87,17 +87,18 @@ for my $id (@ids) { chomp(@msg = @{$pop->get($id)}); } - # Make From_ line - my ($from, $from_alt); + # Find address in From: header and make From_ line + my $from; my $j = 0; # index of empty line before message body for (@msg) { last if /^$/; + if (/^[Ff]rom: / .. not $msg[$j+1] =~ /^[ \t]/) { + /^(?: From:\ | [ \t]+) (.*)/x; + $from .= " $1" if $1; + } $j++; - $from = $1 if /^From: (.*)$/; - $from_alt = $1 if /^from: (.*)$/; } - $from = $from_alt if $from_alt and not $from; - $from = $1 if $from and $from =~ /^.* <(.*?@.*?)>$/; + $from = $1 if $from and $from =~ /^.* <(.*?@.*?)>$/s; $from = 'MAILER-DAEMON@' . hostname if not $from; my $from_ = "From $from $date"; |