1 (edited by craig 2018-02-08 08:08:01)

Topic: Legitimate email from Sendgrid blocked

======== Required information ====
- iRedMail version (check /etc/iredmail-release): Current (see text, the regex is taken from the current source on Bitbucket)
- Linux/BSD distribution name and version:
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):
- Web server (Apache or Nginx):
- Manage mail accounts with iRedAdmin-Pro?: Yes
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

I have been getting complaints from users that expected emails from Sendgrid are not arriving. I looked into this and they are indeed being blocked:

Feb  2 19:27:42 nc027 postfix/smtpd[29988]: NOQUEUE: reject: RCPT from unknown[168.245.3.156]: 554 5.7.1 <o168-245-3-156.outbound-mail.sendgrid.net>: Helo command rejected: ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery. (dynamic); from=<bounces+2353149-2cc0-REDACTED@sendgrid.net> to=<REDACTED> proto=ESMTP helo=<o168-245-3-156.outbound-mail.sendgrid.net>

So this helo (o168-245-3-156.outbound-mail.sendgrid.net) is matching this regex in "hello_access.pcre":

/(\d{1,3}[\.-]\d{1,3}[\.-]\d{1,3}[\.-]\d{1,3})/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1})

I see this regex block a lot of spam, so I am loath to delete it, but it's blocking legitimate email. For this I don't blame iRedMail, I blame Sendgrid.

The question is, are Sendgrid breaking some widely-accepted rule or RFC here in identifying their mail servers with this kind of "helo" (and where can I read this rule), or is this perfectly legitimate and I should modify the regex to exclude Sendgrid?

Thanks.


Craig

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: Legitimate email from Sendgrid blocked

craig wrote:

The question is, are Sendgrid breaking some widely-accepted rule or RFC here in identifying their mail servers with this kind of "helo" (and where can I read this rule), or is this perfectly legitimate and I should modify the regex to exclude Sendgrid?

This HELO hostname is ok.

The problem is too many spammers send emails from a dynamic IP address with IP address in HELO hostname, like they're behind an ADSL cable.

Since the SendGrid hostnames are easy to recognize, you should whitelist it in /etc/postfix/helo_access.pcre like below:

/^o\d{1,3}-\d{1,3}-\d{1,3}-\d{1,3}\.outbound-mail\.sendgrid\.net$/ DUNNO

Note: please place it ABOVE this line:

/(\d{1,3}[\.-]\d{1,3}[\.-]\d{1,3}[\.-]\d{1,3})/ REJECT ACCESS DENIED. Your email was rejected because the sending mail server appears to be on a dynamic IP address that should not be doing direct mail delivery (${1})

The order of rules in helo_access.pcre matters.

3

Re: Legitimate email from Sendgrid blocked

Thanks Zhang. I will do that and see how it goes.

4

Re: Legitimate email from Sendgrid blocked

Worked great. Thanks.