question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not handling reject response correctly when multiple recipients

See original GitHub issue

Similar issues found

#3616

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

  1. Enforce reject rule on unknown recipient domains on your mail server (before any permit rule)
  2. Prepare an email to multiple recipients with at least one ‘bad’ recipient (ex: unknown domain. Ex: nobody@gmail72.com)
  3. Send it from K9-Mail
  4. 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:closed
  • Created 4 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
asaivancommented, Jul 21, 2020

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.

1reaction
popindavibecommented, Jan 8, 2020

@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:

smtpd_recipient_restrictions =
        reject_unauth_pipelining, 
        ## K9 Mail bug 
        ##reject_unknown_recipient_domain, 
        ##reject_non_fqdn_recipient, 
        check_policy_service inet:localhost:9999, 
        permit_sasl_authenticated, 
        reject_non_fqdn_recipient, 
        reject_unknown_recipient_domain,
[..]
Read more comments on GitHub >

github_iconTop Results From Across the Web

Not handling reject response correctly when multiple recipients
My mail server is enforcing a 'reject' rule on unknown recipient domain. So any email containing unknown domain will not be accepted. It...
Read more >
Error handling with promises - The Modern JavaScript Tutorial
Promise chains are great at error handling. When a promise rejects, the control jumps to the closest rejection handler.
Read more >
10 Do's and Don'ts when Dealing with Rejection
There's a correct way to find out why you've been rejected if that's what you're wanting from the situation. Just accept the 'no',...
Read more >
Handling errors in Promise.all - Stack Overflow
Promise.all is all or nothing. It resolves once all promises in the array resolve, or reject as soon as one of them rejects....
Read more >
Sent email in Outlook.com comes back "delivery failed"
Email could not be delivered to members from the group. Try this fix: Review the email addresses that are shown in the error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found