amavisd-release: missing X-Envelope-From or Return-Path

Bernhard Schmidt berni at birkenwald.de
Fri Jan 11 09:02:23 CET 2013


Am 10.01.2013 10:19, schrieb masegaloeh at gmail.com:

Hello Masegaloeh,

>> I have multiple systems running Debian Squeeze with backports, which
>> results in amavisd-new 2.7.1. I looked at the changelog of 2.7.2 and
>> 2.8.0 and did not find anything suspicious in this area, but maybe I
>> missed it.
>>
>> When releasing miscategorized spam using amavisd-release the envelope
>> sender of the released mail is empty.
>>
>> # amavisd-release d/spam-dX5mX6avxljW.gz
>>
>> amavis[5857]: (rel-dX5mX6avxljW) Quarantined message release
>> (miscategorized): dX5mX6avxljW <> -> <recipient1>,<recipient2>
>> amavis[5857]: (rel-dX5mX6avxljW) Quarantine release dX5mX6avxljW:
>> missing X-Envelope-From or Return-Path
>>
>> We're using file-based quarantine, and differently from another thread a
>> few weeks ago the quarantine files do contain a Return-Path (actually
>> several ones in that particular case I was looking at, it's a forwarded
>> spam complaint with two nested message/rfc822 parts, but that does not
>> seem to be the problem as I have the same issue with plain spam).
>>
>> Return-Path: <local.user at domain.de>
>> Delivered-To: spam-quarantine
>> X-Envelope-To: <recipient1>,<recipient2>
>> X-Envelope-To-Blocked: <recipient1>,<recipient2>
>> X-Quarantine-ID: <dX5mX6avxljW>
>> X-Spam-Flag: YES
>> X-Spam-Score: 10.32
>> X-Spam-Level: **********
>> X-Spam-Status: Yes, score=10.32 tag=-999 tag2=5 kill=10
>> tests=[BAYES_95=3,
>>          DEAR_BENEFICIARY=3.699, HTML_MESSAGE=0.001, LOTS_OF_MONEY=0.001,
>>          MONEY_ATM_CARD=3.599, T_FILL_THIS_FORM_SHORT=0.01,
>> T_FRT_FUCK1=0.01]
>>          autolearn=disabled
>>
>> Any ideas where to look? I looked at the msg_from_quarantine function
>> but I am not entirely convinced I get it correctly.
>>
>> Thanks,
>> Bernhard
>>
> Hello,
> 
> I have similar problem (actually I created similar thread several weeks
> ago). My workaround was a small-ugly-patch in amavisd script, so the
> quarantined mail always contains X-Envelope-From header. After the
> pacth, the maillog looks happy when I release an email
> 
> # grep rel-Ju4V81aWl1eu /var/log/maillog
> Jan 10 16:07:44 server amavis[92626]: (rel-Ju4V81aWl1eu) Quarantined
> message release (miscategorized): Ju4V81aWl1eu <sender at example.org> ->
> <recipient at example.org>
> 
> If you interested in it, my unofficial small-ugly-patch for version
> 2.8.0 was attached below.
> 
> I hope there is an official workaround for this problem.

Thanks to your hint I think I got it this time. Looks like a bug to me.

$orig_env_sender_retained gets set when either mailfrom_to_quarantine is
undefined or the quarantine is BSMTP or SQL

14380     my($mftq) = c('mailfrom_to_quarantine');
14381     if (!defined $mftq || $quar_m_protocol =~ /^(?:bsmtp|sql)\z/) {
14382       # we keep the original envelope sender address if
replacement sender
14383       # is not provided, or with quarantine methods which store to
fixed
14384       # locations which do not depend on envelope
14385       $quar_msg->sender($msginfo->sender);  # original sender
14386       $quar_msg->sender_smtp($msginfo->sender_smtp);
14387       $orig_env_sender_retained = 1;

If that is set, X-Envelope-From is added, that is the part you made
execute unconditionally.

14442     if (!$orig_env_sender_retained) { # unless X-Envelope-* would
be redundant
14443       $hdr_edits->prepend_header('X-Envelope-From',
$msginfo->sender_smtp);
14444     }

What was totally confusing me is that while amavisd complaints about
missing Return-Path OR X-Envelope-From

 9843   push(@m, 'missing '.($bsmtp?'MAIL FROM':'X-Envelope-From or
Return-Path'))
 9844     if !defined $sender;

it is actually only setting $sender on X-Envelope-From

 9793       } elsif (!$bsmtp && /^Return-Path:[ \t]*(.*)$/si) {
 9794       } elsif (!$bsmtp && /^Delivered-To:[ \t]*(.*)$/si) {
 9795       } elsif (!$bsmtp && /^X-Envelope-From:[ \t]*(.*)$/si) {
 9796         if (!defined $sender) {
 9797           my(@addr_list) = parse_address_list($1);
 9798           @addr_list >= 1  or die "Address missing in
X-Envelope-From";
 9799           @addr_list <= 1  or die "More than one address in
X-Envelope-From";
 9800           $sender = unquote_rfc2821_local($addr_list[0]);
 9801         }

The only thing I am not getting is that I should be hitting the codepath
adding X-Envelope-From, because mailfrom_to_quarantine is nowhere in my
configuration nor set in amavisd-new, so it should be undef... but it's
not in the quarantine file.


Best Regards,
Bernhard


More information about the amavis-users mailing list