Not handling reject response correctly when multiple recipients
See original GitHub issueSimilar issues found
Root Cause
My mail server is enforcing a ‘reject’ rule on unknown recipient domain. So any email containing unknown domain will not be accepted. It works with other MUA I tested, and indeed the 450 error is raised and no mail is sent until the list of recipients is sanitized. In the case of K9-Mail, I end up with a mangled header missing multiple fields (From / Date) and with an ‘unexpected end of header’. For Googlemail, the server respond waving RFC 5322 and refuse to accept the email. Others will discard and send a report to the recipient regarding the bad formatted email, and Outlook/Microsoft will accept it but it will be blank for the recipient. On K9-Mail side, the email will be stuck forever in the Outbox, trying to resend the botched email every now and then, never succeeding (as expected).
Expected behavior
Whenever a recipient is rejected, the MUA should handle it gracefully. Testing with Thunderbird and SOGo, they both raise the error and do not try further attempts to deliver the email until the ‘bad’ recipients have been removed from the list.
K9-Mail should do the same and stop all attempt on receiving the reject from the mail server until the list of recipients has been sanitized.
Actual behavior
Mail server rejects the email, with and from=<> as per bouncing standards, however K9-Mail basically integrate that bad-formatted header and use it to try sending the email to the rest of the recipients.
Steps to reproduce
- Enforce reject rule on unknown recipient domains on your mail server (before any permit rule)
- Prepare an email to multiple recipients with at least one ‘bad’ recipient (ex: unknown domain. Ex: nobody@gmail72.com)
- Send it from K9-Mail
- Check your Outbox in K9-Mail and your logs on the mail server
Environment
K-9 Mail version: 5.500
Android version: 8.1.0
Account type (IMAP, POP3, WebDAV/Exchange): IMAP
Please take some time to retrieve logs and attach them here:
Logs from the mail server:
Jul 23 09:44:35 myhost postfix/smtpd[26369]: connect from XXX.XXX.XXX.137.threembb.co.uk[XXX.XXX.XXX.137]
Jul 23 09:44:35 myhost postfix/smtpd[26369]: Anonymous TLS connection established from XXX.XXX.XXX.137.threembb.co.uk[XXX.XXX.XXX.137]: TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)
Jul 23 09:44:35 myhost postfix/smtpd[26369]: CEC231003: client=XXX.XXX.XXX.137.threembb.co.uk[XXX.XXX.XXX.137], sasl_method=PLAIN, sasl_username=obsucated-p@domain.fr
Jul 23 09:44:35 myhost postfix/smtpd[26369]: CEC231003: reject: RCPT from XXX.XXX.XXX.137.threembb.co.uk[XXX.XXX.XXX.137]: 450 4.1.2 <obsucated-t@domain.com>: <b>Recipient address rejected: Domain not found</b>; from=<obsucated-p@domain.fr> to=<obsucated-t@domain.com> proto=ESMTP helo=<[XXX.XXX.XXX.119]>
Jul 23 09:44:36 myhost postfix/cleanup[26374]: CEC231003: message-id=<>
Jul 23 09:44:36 myhost opendkim[32642]: <b>CEC231003: can't determine message sender; accepting</b>
Jul 23 09:44:36 myhost opendmarc[619]: CEC231003: RFC5322 requirement error: missing From field; accepting
Jul 23 09:44:36 myhost postfix/qmgr[26269]: CEC231003: from=<obsucated-p@domain.fr>, size=213, nrcpt=2 (queue active)
Jul 23 09:44:36 myhost postfix/smtp[26375]: Untrusted TLS connection established to gmail-smtp-in.l.google.com[2a00:1450:400c:c0a::1b]:25: TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)
Jul 23 09:44:36 myhost postfix/smtpd[26369]: disconnect from XXX.XXX.XXX.137.threembb.co.uk[XXX.XXX.XXX.137] ehlo=2 starttls=1 auth=1 mail=1 rcpt=2/3 data=1 quit=1 commands=9/10
Jul 23 09:44:36 myhost postfix/smtp[26375]: CEC231003: to=<obsucated-j@domain.com>, relay=gmail-smtp-in.l.google.com[2a00:1450:400c:c0a::1b]:25, delay=0.99, delays=0.4/0.01/0.16/0.43, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[2a00:1450:400c:c0a::1b] said: 550-5.7.1 [2a01:4f8:10a:2493:b827:a8ff:fe4b:b71c 11] Our system has 550-5.7.1 detected that this message is not RFC 5322 compliant: 550-5.7.1 'From' header is missing. 550-5.7.1 To reduce the amount of spam sent to Gmail, this message has been 550-5.7.1 blocked. Please visit 550-5.7.1 https://support.google.com/mail/?p=RfcMessageNonCompliant 550 5.7.1 and review RFC 5322 specifications for more information. y4si40902182wrr.356 - gsmtp (in reply to end of DATA command))
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (3 by maintainers)
Top GitHub Comments
Hello, K-9 team,
I want to also chime in on this as this is an issue that we’ve been seeing in K-9 for years now, and have only just now been able to pin down the cause of the problem and we can confirm that it’s indeed issue as described above. K-9 doesn’t handle rejects set by Postfix in a graceful way, and so we have emails with blank bodies sent out, resulting in confusion and messages not going through properly. For our organization this is a critical issue and we hope that this problem can be addressed soon.
Thank you for your attention to this matter.
@Fjorstut if you administer the mail server, a workaround (until this is addressed) is to lower the reject rules for unknown recipient domain and non fqdn recipient.
On postfix this is what I set up: