I have a DigitalOcean server which runs Ubuntu 14.04. I am having problems with sending emails from the PHP
mail() function (which uses
I think the issue may be related to my
hosts file config. Here is what I have in
/etc/hosts at the moment:
127.0.0.1 localhost localhost.localdomain ip-xxx-xxx-xxx-xxx
(In the above two, I replaced the IP address digits with
Now I have a domain pointing to this server, let's call this
So when my website
mydomain.com sends an email, the email is going in to the junk mail folder. I ran a test on https://www.mail-tester.com and one of the issues it flags up is:
I have tried adding
mydomain.com to the line above in the
hosts file but this results in the email arriving after a long time or not arriving at all.
Here are the Received headers:
Received: from localhost.localdomain (unknown [xxx.xxx.xxx.xxx]) (using TLSv1.2 with cipher xxx (256/256 bits)) (No client certificate requested) by mail-tester.com (Postfix) with ESMTPS id xxx for <email@example.com>; Mon, 29 Apr 2019 18:35:18 +0200 (CEST) Received: from localhost.localdomain (localhost [127.0.0.1]) by localhost.localdomain (8.15.2/8.15.2/Debian-3) with ESMTP id xxx for <firstname.lastname@example.org>; Mon, 29 Apr 2019 17:35:18 +0100 Received: from mydomain.com (www-data@localhost) by localhost.localdomain (8.15.2/8.15.2/Submit) with SMTP id xxx for <email@example.com>; Mon, 29 Apr 2019 17:35:18 +0100
How to fix?