Syntax error in MAIL FROM parameters

Dauser Martin Johannes mdauser at cs.sbg.ac.at
Sun Feb 18 02:51:11 CET 2018


On Sat, 2018-02-17 at 23:31 +0100, Dauser Martin Johannes wrote:
> On Sat, 2018-02-17 at 16:38 +0100, Christian Boltz wrote:
> > Hello,
> > 
> > does someone know what Amavis wants to tell me with this message,
> > and
> > how to avoid these rejects?
> > (the mail address is anonymized starting at "user=")
> > 
> > Feb 15 12:38:28 server amavis[3273]: (03273-17) ESMTP: 501 5.5.4
> > Syntax error in MAIL FROM parameters; smtp_resp: MAIL
> > FROM:<bounce+28
> > f75a.232d6-user=example.com at mail.example2.com> BODY=8BITMIME
> > SMTPUTF8\r\n
> > 
> 
> 
> > Looking at the amavis source code in /usr/sbin/amavisd shows
> > (starting at line 20555)
> > 
> >         my($addr,$opt) = ($1,$2);  my($size,$dsn_ret,$dsn_envid);
> >         my $msg ; my $msg_nopenalize = 0;
> >         for (split(' ',$opt)) {
> >           if (!/^ ( [A-Za-z0-9] [A-Za-z0-9-]*  ) =
> >                   ( [\041-\074\076-\176]+ ) \z/xs) { # printable,
> > not
> > '=' or SP
> >             $msg = "501 5.5.4 Syntax error in MAIL FROM
> > parameters";
> >           } else {
> > 
> > as likely source of the problem - at least, that's the only place
> > where
> > I found the error message.
> > 
> > Does someone know how I can avoid those rejects?
> > 
> > 
> > Regards,
> > 
> > Christian Boltz
> 
> As this seems to be the only occurrence, it's most likely the
> relevant
> code.
> 
> I tried to phrase the main part of this if-clause's condition in a
> sentence. I included the round brackets of the code.
> 
> If (not starting ( with an alphanumeric sign, followed by none or any
> amount of alphanumeric signs, including '-'), followed by '=' ,(
> followed by at least one alphanumeric sign, including sings like '!',
> '[', '.' and so on, except for '=' and empty space) \z/xs)
> 
> then message $msg becomes "501 5.5.4 Syntax error in MAIL FROM
> parameters"
> 
> Your
> <bounce+28f75a.232d6-user=example.com at mail.example2.com>
> 
> includes a '<', a '+' and a '.' before '=' which isn't allowed by
> this
> if-clause. But beforehand the code splits some $opt in substrings
> (separator is one empty space), so I'm not 100% sure what this if-
> clause is looking at.
> 
Just looked at the lines executed right before. The code evaluates some
'<address> option1 option2 ...' and then this if-clause looks at those
options!

BODY=8BITMIME SMTPUTF8\r\n

SMTPUTF8\r\n seems to be the trigger -- not sure if '\r\n' is part of
the option or added by the error message. In fact SMTPUTF8 is a defined
option I already read about.

But the culprit is the (old?) perl code:
 
My if-clause looks a bit different (EPEL Repository for RHEL7)

 my($addr,$opt) = ($1,$2);
 my($size,$dsn_ret,$dsn_envid,$smtputf8);
 my $msg; my $msg_nopenalize = 0;
 for (split(' ',$opt)) {
   if (!/^ ( [A-Za-z0-9] [A-Za-z0-9-]* )
           (?: = ( [^=\000-\040\177]+ ) )? \z/xs) {
           # any CHAR excluding "=", SP, and control characters
     $msg = "501 5.5.4 Syntax error in MAIL FROM parameters";
   } else 

Let's rephrase that:

if (not starting ( with an alphanumeric sign, followed by none or any
amount of alphanumeric signs, including '-'), (followed once or never
by '=' , which is then (followed by none or any amount of signs NOT
being '=' , an oktalASCII 000 to 040 or oktalASCII 176)) \z/xs)

So now, an option might be entirely without '=' but needs then to be
made of alphanumeric signs and might include '-'. This '\r\n' won't do.

If the option includes  '=' the right part may contain any ASCII char
excluding "=", space and (non-printable) control characters.


> I hope this helps a bit.
> Martin Johannes Dauser


More information about the amavis-users mailing list