Our production server for clients is hosted on an cloud compute instance on AWS and runs on WHM. One of our clients wants to use their own SMTP servers so we decided to use WP MAIL SMTP plugin from wordpress which configures the WordPress website to send emails using SMTP. All good so far until we test it and we found out it always failed to send our test email with the error above. We double check our credentials and all are correct. We debug further by trying to communicate with the external SMTP servers via SSH using telnet on the specified port and we successfully connected. Upon further debugging, it turns out this was caused by a WHM settings that restricts any direct external SMTP connections and routed all to the local mail server. By configuring on WHM > Tweak Settings > All> “Restrict outgoing SMTP to root, exim, and mailman (FKA SMTP Tweak) and switch it from “On” to “Off”. We are now able to send emails using external SMTP servers directly at application code level.

You can also turn that off via SSH:

1

/scripts/smtpmailgidonly off

make sure also that From Email matches the email address on your mailboxes.