[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-anubis] add header[] puts headers in body
From: |
Paolo |
Subject: |
Re: [bug-anubis] add header[] puts headers in body |
Date: |
Tue, 31 Aug 2004 21:48:03 +0200 |
User-agent: |
Mutt/1.3.28i |
On Tue, Aug 31, 2004 at 12:58:16PM +0300, Sergey Poznyakoff wrote:
> Hi Paolo,
>
> > Sent message (full text - but no Status: etc., as stored in an mbox,
> > bounced
> > by mutt to address@hidden, trough msg2smtp.pl):
> > #--------------------------------
> > From paolo Tue Aug 31 01:56:41 2004
>
> This is wrong. msg2smtp.pl assumes its input is a valid RFC822 message,
> i.e. it must consist of a bunch of headers, then an empty line ('\n'
> on a line by itself, and then a body. Starting the message with
> 'From ' confuses msg2smtp.pl, as a result it sends the message
> without newline separator, so that it appears to Anubis as malformed
> headers without a body.
hmmm... ok; then I reply to a msg, instead of bouncing it, but I get same
result; msg2smtp.pl is invoked as described in msg2smtp.txt.
Of course, everything is nice in default mutt<->MTA situation.
Seems that mutt doesn't output a 'From:' line, in its default config (on
Debian), so the problem seems to be msg2smtp.pl, which never exits headers
parser despite the blank line (doesn't set $readyflag).
Pls see attached diff of my hacked version against msg2smtp.pl in 3.9.95
- now this WFM, hope it's useful to others.
mods:
- exit anyway header-parser on blank line
- check later for a valid To:|Cc:|Bcc:, exit and issue an error if not
- don't bother 'From:', if it's there take it, else crop up a default one.
- blank the 'From ' line
thanks
-- paolo
GPG/PGP id:0x21426690 kfp:EDFB 0103 A8D8 4180 8AB5 D59E 9771 0F28 2142 6690
8<--[msg2smtp.pl.diff]-------------
--- /var/tmp/anubis-3.9.95/contrib/msg2smtp.pl Wed Feb 12 13:31:28 2003
+++ /usr/local/bin/msg2smtp.pl Tue Aug 31 20:30:03 2004
@@ -116,15 +116,16 @@
$readyflag = 0;
HEAD: while ($tmp = <STDIN>) {
-
# Rule 1: If the line is a blank line, exit HEAD section
if ($tmp =~ /^$/) {
- if ($readyflag eq 1) {
+ # don't use the $readyflag flag, if we got a blank line we exit
+ # headers parser anyway - we'll check later if we got To: and From:
+ # if ($readyflag eq 1) {
last;
- }
- else {
- next HEAD;
- }
+ # }
+ # else {
+ # next HEAD;
+ # }
}
# Rule 2: If it is a folded line, add line to $chunk, skip to next line
@@ -139,7 +140,10 @@
$from = pop(@from_addresses)->address;
die "From: address invalid" unless $from;
die "there is more than one From: address" if @from_addresses;
- $readyflag = 1;
+ $from .="address@hidden" if ($from !~ /\@/);
+ } elsif (/^From /i) {
+ # get rid of spurious 'From ' line
+ $chunk = '';
} elsif (/^(To|CC|BCC):/i) {
s/^(To|CC|BCC)://i;
@to_addresses = (); # re-initialize because we re-enter this loop
@@ -147,6 +151,7 @@
foreach my $obj (@to_addresses) {
push @rcpt, $obj->address;
}
+ $readyflag = 1;
}
$txt_head .= $chunk if ($chunk);
@@ -154,16 +159,26 @@
$chunk = $tmp;
}
+# if we did not see a 'From:' line, synthetize a reasonable default
+$from = "$ENV{'USER'address@hidden" if(!$from);
+# we really must have one of these
+die "To|Cc|Bcc: address(es) invalid or missing" unless $readyflag;
+
while (<STDIN>) {
$txt_body .= $_;
}
-#if ($smtp_options{Debug}) {
-# print "\n---BEGINNING OF DEBUG---\n";
-# print "From: $from\n"; map {print "To: $_\n"} @rcpt;
-# print "MsgBody:\n$txt_body\n";
-# print "---END OF DEBUG---\n";
-#}
+if ($smtp_options{Debug}) {
+ print STDERR "\n---BEGINNING OF DEBUG---\n";
+ print STDERR "--From:, To:--\n";
+ print STDERR "From: $from\n" if ($from);
+ map {print "To: $_\n"} @rcpt;
+ print STDERR "\n--All headers:--\n";
+ print STDERR "$txt_head\n" if($txt_head);
+ print STDERR "--MsgBody:--\n";
+ print STDERR "$txt_body\n" if($txt_body);
+ print STDERR "---END OF DEBUG---\n";
+}
#------------------------------------------
# 4. Extend Net::SMTP to allow us to choose and auth mechanism
8<-----------------------------------