I get this error frequently when I use the PHPMailer library, i.e. for a WordPress site.
The strange thing is, this will work on your localhost but not on the remote server.
It is not a problem with PHPMailer, or WordPress, or your mail server.
It is a problem with your hosting configuration (I’m using Namecheap for hosting but I assume you have cPanel installed).
How to fix:
- Log into cPanel, and under the “Mail” section, choose “MX Entry”.
- Add MX records as shown below. (I’m using Zoho as my mail server, and their addresses are mx.zoho.com and mx2.zoho.com)