550 Bad HELO - Host impersonating hostname

I’m getting a Bad HELO error after setting up Discourse.

I’ve done some digging and found that this can be an issue if the reverse DNS does not match the hostname in some cases.

In my case my config has the mailserver hostname on a shared DirectAdmin server so I’m setting up Discourse on a domain that differs from the hostname domain.

  DISCOURSE_SMTP_ADDRESS: mail.example.com
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: discourse@example.com
  DISCOURSE_SMTP_PASSWORD: "my_password_without_hash"
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (optional, default true)
  DISCOURSE_SMTP_DOMAIN: 20.example.org #note the DirectAdmin domain differs from my domain.
  DISCOURSE_NOTIFICATION_EMAIL: noreply@example.com

It’s quite likely that it’s objecting to your reverse DNS entry not matching, for example you connect from an IP and say EHLO domainname.com, the receiving server does a reverse lookup on that and finds www.domainname.com, which isn’t an exact match, and so it complains/rejects. It’s not an SMTP spec contravention, but it is common anti-spam, anti-forgery practice.

PHPMailer will derive the SMTP envelope sender address from the From address by default, but you can override that using the Hostname property (not the same thing as Host), for example:

$mail->From = 'user@domainname.com';
$mail->Hostname = 'www.domainname.com';
https://github.com/PHPMailer/PHPMailer/issues/1095

Does

  dig -x your.ip.number

Have your host name?

Hi Jay,

Discourse is not allowing met to post links in a reply just yet. So I’ll respond with dot instead of a period. Hope it keeps things clear.

Yes when I run this command against the VPS that discourse is on I get the hostname that discourse is running on. i.e. discourse dot example dot com.

If I run this against the Shared server (where the mailserver is) I get it’s hostname i.e. above 20 dot example dot org. Not example dot com. Technically example dot com resolves to the shared server’s IP. But the shared server has another hostname (20 dot example dot org).