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: firstname.lastname@example.org 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: email@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 = 'firstname.lastname@example.org'; $mail->Hostname = 'www.domainname.com';