0

We've successfully migrated from an ancient Microsoft Exchange to dovecot+postfix and everything works fine except from one particular case:

When users of Outlook 2016 hit reply on an old mail from someone within the company (someone@example.com) they get a delivery error from Outlook and sometimes I notice that Outlook doesn't even make a connection to the SMTP server and other times it makes one and gets an error (see below). If they hit forward and type the same address (someone@example.com) manually everything is OK.

The non-delivery-notification email that comes back is in the lines of (translation from Greek):

We couldn't reach one or more recipients... 
   'Company S.A. John Smith' at 22/10/2018 1:03 pm
Server error: '501 5.1.3 Bad recipient address syntax'" 

and postfix has this line in the logs:

postfix/smtps/smtpd[3905]: warning: Illegal address syntax from xxx.yyy.local[192.168.0.153] in RCPT command: <Company S.A. John Smith>

Users that have Thunderbird have no problem at all. Both Outlook and Thunderbird are using the same connection settings for the server (secure IMAP and SMTP)

Any ideas on what goes wrong here would be highly appreciated.

ndemou
  • 1,215
  • 2
  • 16
  • 27
  • Any words or numbers in that error? – Greg Askew Oct 22 '18 at 12:32
  • I believe Outlook cached some stuff. I've seen it before that when typing an email address in the "To" field, it autocompletes it incorrectly. I needed to remove that address and add it anew to make it work. I don't know a structural solution though :( – Tommiie Oct 22 '18 at 12:46
  • Sorry for the luck of useful information. I've just added what I could gather from both the server and client. It seems that Outlook tries to send email to the free text "description" of the recipient instead of the email address. – ndemou Oct 22 '18 at 12:57
  • 1
    This is an old and well known issue when migrating users from Exchange. Have a read here - http://www.enowsoftware.com/solutions-engine/bid/151745/The-Attribute-the-Myth-the-legacyExchangeDN – joeqwerty Oct 22 '18 at 14:10
  • Many thanks @joeqwerty. Your link seems to be on target but it's not a light reading. I'll need a bit of time and concentration to digest it. – ndemou Oct 22 '18 at 14:30
  • Based on a *very* fast look on joeqwerty's link it seems to me that the malformed addresses come from outlook's name cache (.nk2 file). I'll try to clear it tomorrow see if it fixes the problem. – ndemou Oct 22 '18 at 14:54

2 Answers2

1

The malformed addresses come from outlook's name cache (the .nk2 file). You have to remove all the entries of the .nk2 file that correspond to exchange addresses.

In my case I used a free editor by Nirsoft to edit the file. I clicked the Address column header to sort by Address Type and I selected all the entries showing EX instead of SMTP. Then I hit delete and save.

Thanks to everybody for the helpful comments and joeqwerty in particular for the very informative link that guided me to the right direction.

ndemou
  • 1,215
  • 2
  • 16
  • 27
  • Really Funny! This is my first answer with a negative score and it's for a question from *myself*. Naturally I've posted it because it solved my problem. – ndemou Oct 25 '18 at 11:01
0

The destination address in the log entry is Company S.A. John Smith. Postfix is right when it complains about that as spaces in email addresses require quoting and the address must have a @ character followed by the domain.

The relevant standards to look at are RFC 5321:

   Forward-path   = Path

   Path           = "<" [ A-d-l ":" ] Mailbox ">"

   A-d-l          = At-domain *( "," At-domain )
                  ; Note that this form, the so-called "source
                  ; route", MUST BE accepted, SHOULD NOT be
                  ; generated, and SHOULD be ignored.

   At-domain      = "@" Domain

   Mail-parameters  = esmtp-param *(SP esmtp-param)

   Rcpt-parameters  = esmtp-param *(SP esmtp-param)

   esmtp-param    = esmtp-keyword ["=" esmtp-value]

   esmtp-keyword  = (ALPHA / DIGIT) *(ALPHA / DIGIT / "-")

   esmtp-value    = 1*(%d33-60 / %d62-126)
                  ; any CHAR excluding "=", SP, and control
                  ; characters.  If this string is an email address,
                  ; i.e., a Mailbox, then the "xtext" syntax [32]
                  ; SHOULD be used.

   Keyword        = Ldh-str

   Argument       = Atom

   Domain         = sub-domain *("." sub-domain)

   sub-domain     = Let-dig [Ldh-str]

   Let-dig        = ALPHA / DIGIT

   Ldh-str        = *( ALPHA / DIGIT / "-" ) Let-dig

   address-literal  = "[" ( IPv4-address-literal /
                    IPv6-address-literal /
                    General-address-literal ) "]"
                    ; See Section 4.1.3

   Mailbox        = Local-part "@" ( Domain / address-literal )

   Local-part     = Dot-string / Quoted-string
                  ; MAY be case-sensitive


   Dot-string     = Atom *("."  Atom)

   Atom           = 1*atext

   Quoted-string  = DQUOTE *QcontentSMTP DQUOTE

and RFC 5322:

   atext           =   ALPHA / DIGIT /    ; Printable US-ASCII
                       "!" / "#" /        ;  characters not including
                       "$" / "%" /        ;  specials.  Used for atoms.
                       "&" / "'" /
                       "*" / "+" /
                       "-" / "/" /
                       "=" / "?" /
                       "^" / "_" /
                       "`" / "{" /
                       "|" / "}" /
                       "~"

The only exception to the requirement for @ and domain in the recipient address is that the reserved address postmaster can be used without domain to send an email to the administrator of the relevant mail server.

Even if Postfix had relaxed its parsing enough to not complain about the two syntax errors I guess you probably haven't configured Postfix to know how to deliver an email to Company S.A. John Smith.

The next question then is why Outlook produce such an incorrect RCPT command in the first place. To understand you need to look at the email being responded to on the client side to see what the From and Reply-To headers in the mail look like.

kasperd
  • 29,894
  • 16
  • 72
  • 122
  • Thanks kasperd. I wonder why is Outlook using this invalid RCPT TO address in the first place and what can I do to prevent it. Answering your questions: There is no exchange in this network anymore. There is no "Reply-To" header and the "From" header has this form: "Company S.A. John Smith" – ndemou Oct 22 '18 at 14:34
  • 1
    @ndemou In order to understand that `From` header, one has to read [section 3.4](https://tools.ietf.org/html/rfc5322#section-3.4) of [https://tools.ietf.org/html/rfc5322](RFC 5322). And from there we can see that a quoted name followed by address in angle-brackets is a valid syntax. So the question now is, why does Outlook sometimes pick the wrong part of that `From` header, when it needs to extract the email address. That's beyond what I could answer, and it sounds like a bug in Outlook. – kasperd Oct 22 '18 at 14:57