Unable to send mail remotely, but can locally

youds

Verified User
Joined
Jul 11, 2008
Messages
475
Location
Lancashire, UK
Hello!

I am able to send email via PHP to email accounts registered on the server code is executed from but to iCloud and gmail nothing arrives. I get the following output from PHPMailer:
2025-01-08 15:07:44 SERVER -> CLIENT: 220 server2.uk.gethosted.online ESMTP Exim 4.98 Wed, 08 Jan 2025 15:07:44 +0000
2025-01-08 15:07:44 CLIENT -> SERVER: EHLO 01.youds.dev
2025-01-08 15:07:44 SERVER -> CLIENT: 250-server2.uk.gethosted.online Hello 01.youds.dev [63.135.75.90]250-SIZE 52428800250-LIMITS MAILMAX=100 RCPTMAX=150250-8BITMIME250-PIPELINING250-PIPECONNECT250-AUTH PLAIN LOGIN250 HELP
2025-01-08 15:07:44 CLIENT -> SERVER: AUTH LOGIN
2025-01-08 15:07:44 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2025-01-08 15:07:44 CLIENT -> SERVER: [credentials hidden]
2025-01-08 15:07:44 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2025-01-08 15:07:44 CLIENT -> SERVER: [credentials hidden]
2025-01-08 15:07:44 SERVER -> CLIENT: 235 Authentication succeeded
2025-01-08 15:07:44 CLIENT -> SERVER: MAIL FROM:<support@****.com>
2025-01-08 15:07:44 SERVER -> CLIENT: 250 OK
2025-01-08 15:07:44 CLIENT -> SERVER: RCPT TO:<[email protected]>
2025-01-08 15:07:44 SERVER -> CLIENT: 250 Accepted
2025-01-08 15:07:44 CLIENT -> SERVER: DATA
2025-01-08 15:07:44 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
2025-01-08 15:07:44 CLIENT -> SERVER: Date: Wed, 8 Jan 2025 15:07:44 +0000
2025-01-08 15:07:44 CLIENT -> SERVER: To: macen <[email protected]>
2025-01-08 15:07:44 CLIENT -> SERVER: From: ***** <support@*****.com>
2025-01-08 15:07:44 CLIENT -> SERVER: Reply-To: ***** NO-REPLY <no-reply@*****.com>
2025-01-08 15:07:44 CLIENT -> SERVER: Subject: Here is the subject
2025-01-08 15:07:44 CLIENT -> SERVER: Message-ID: <[email protected]>
2025-01-08 15:07:44 CLIENT -> SERVER: X-Mailer: PHPMailer 6.9.3 (https://github.com/PHPMailer/PHPMailer)
2025-01-08 15:07:44 CLIENT -> SERVER: MIME-Version: 1.0
2025-01-08 15:07:44 CLIENT -> SERVER: Content-Type: multipart/alternative;
2025-01-08 15:07:44 CLIENT -> SERVER: boundary="b1=_W4FqdzKxDoAaDk7LHZrFFhWc6izTepdq947Ug2X6N8"
2025-01-08 15:07:44 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2025-01-08 15:07:44 CLIENT -> SERVER:
2025-01-08 15:07:44 CLIENT -> SERVER: --b1=_W4FqdzKxDoAaDk7LHZrFFhWc6izTepdq947Ug2X6N8
2025-01-08 15:07:44 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2025-01-08 15:07:44 CLIENT -> SERVER:
2025-01-08 15:07:44 CLIENT -> SERVER: This is the body in plain text for non-HTML mail clients
2025-01-08 15:07:44 CLIENT -> SERVER:
2025-01-08 15:07:44 CLIENT -> SERVER: --b1=_W4FqdzKxDoAaDk7LHZrFFhWc6izTepdq947Ug2X6N8
2025-01-08 15:07:44 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2025-01-08 15:07:44 CLIENT -> SERVER:
2025-01-08 15:07:44 CLIENT -> SERVER: This is the HTML message body <b>in bold!</b>
2025-01-08 15:07:44 CLIENT -> SERVER:
2025-01-08 15:07:44 CLIENT -> SERVER:
2025-01-08 15:07:44 CLIENT -> SERVER: --b1=_W4FqdzKxDoAaDk7LHZrFFhWc6izTepdq947Ug2X6N8--
2025-01-08 15:07:44 CLIENT -> SERVER:
2025-01-08 15:07:44 CLIENT -> SERVER: .
2025-01-08 15:07:45 SERVER -> CLIENT: 250 OK id=1tVXeq-000000095LV-41tR
2025-01-08 15:07:45 CLIENT -> SERVER: QUIT
2025-01-08 15:07:45 SERVER -> CLIENT: 221 server2.uk.gethosted.online closing connection
Message has been sent

I can't find anywhere in `/var/log/exim` any trace of the email. If I use mail() then I can see in `/home/project/.php/php-mail.log` the mail being sent but no error and nothing arrives. I've tried from my local dev server using standard mail functionality but nothing works, unless I send locally.

I remember having this problem many years ago but can't trace the fix from Google.

Any ideas what this could be?
 
Any ideas what this could be?
Might be caused by invalid hostname. Check this:
Code:
CLIENT: 250-server2.uk.gethosted.online Hello 01.youds.dev [63.135.75.90]

Then check intodns.com.
So gethosted.online is used as main host.
But the helo says 01.youds.dev is that your hostname? Because that has a totally different ip than your MX record.
mail.youds.dev MX 95.164.119.207
Now it's possible to receive mail and send mail from different servers.
But looking aqt the helo/ehlo here, your system is sending from the 63.135.75.90 ip address which does not have any rDNS/PTR record.
And normally, if you don't use authentication in php mailer, the hostname is used for outgoing mail.
Also at this exact moment 63.135.75.90 is not listening to port 25. Maybe reboot but you have to check this if your Exim is running on that ip. It -is- however listening on mail.yourdomain.dev but there it's responlding with the xxxx.xxx.gethosted.online hostname.

So either force your script to use authentication or use that hostname, or if you want to run your mailserver on your 01.youds.dev hostname, then you have to change some more things and setup an rDNS/PTR record for it.
 
Apologies, I have included the code debug output ran from our production server. The previous one was my dev server.

For clarity, I am using SMTP with an operational email account and it can send locally but not remotely.

2025-01-08 17:24:54 SERVER -> CLIENT: 220 server2.uk.gethosted.online ESMTP Exim 4.98 Wed, 08 Jan 2025 17:24:54 +0000
2025-01-08 17:24:54 CLIENT -> SERVER: EHLO *****.com
2025-01-08 17:24:54 SERVER -> CLIENT: 250-server2.uk.gethosted.online Hello server2.uk.gethosted.online [38.45.200.204]250-SIZE 52428800250-LIMITS MAILMAX=100 RCPTMAX=150250-8BITMIME250-PIPELINING250-PIPECONNECT250-AUTH PLAIN LOGIN250 HELP
2025-01-08 17:24:54 CLIENT -> SERVER: AUTH LOGIN
2025-01-08 17:24:54 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2025-01-08 17:24:54 CLIENT -> SERVER: [credentials hidden]
2025-01-08 17:24:54 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2025-01-08 17:24:54 CLIENT -> SERVER: [credentials hidden]
2025-01-08 17:24:54 SERVER -> CLIENT: 235 Authentication succeeded
2025-01-08 17:24:54 CLIENT -> SERVER: MAIL FROM:<support@*****.com>
2025-01-08 17:24:54 SERVER -> CLIENT: 250 OK
2025-01-08 17:24:54 CLIENT -> SERVER: RCPT TO:<[email protected]>
2025-01-08 17:24:54 SERVER -> CLIENT: 250 Accepted
2025-01-08 17:24:54 CLIENT -> SERVER: DATA
2025-01-08 17:24:54 SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself
2025-01-08 17:24:54 CLIENT -> SERVER: Date: Wed, 8 Jan 2025 17:24:53 +0000
2025-01-08 17:24:54 CLIENT -> SERVER: To: macen <[email protected]>
2025-01-08 17:24:54 CLIENT -> SERVER: From: ***** <support@*****.com>
2025-01-08 17:24:54 CLIENT -> SERVER: Reply-To: ***** NO-REPLY <no-reply@*****.com>
2025-01-08 17:24:54 CLIENT -> SERVER: Subject: Here is the subject
2025-01-08 17:24:54 CLIENT -> SERVER: Message-ID: <hTX5faPZ0GNL7dgpuJaQTDEPmxJrAXJ8L71qgkz9Ow@*****.com>
2025-01-08 17:24:54 CLIENT -> SERVER: X-Mailer: PHPMailer 6.9.3 (https://github.com/PHPMailer/PHPMailer)
2025-01-08 17:24:54 CLIENT -> SERVER: MIME-Version: 1.0
2025-01-08 17:24:54 CLIENT -> SERVER: Content-Type: multipart/alternative;
2025-01-08 17:24:54 CLIENT -> SERVER: boundary="b1=_hTX5faPZ0GNL7dgpuJaQTDEPmxJrAXJ8L71qgkz9Ow"
2025-01-08 17:24:54 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2025-01-08 17:24:54 CLIENT -> SERVER:
2025-01-08 17:24:54 CLIENT -> SERVER: --b1=_hTX5faPZ0GNL7dgpuJaQTDEPmxJrAXJ8L71qgkz9Ow
2025-01-08 17:24:54 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2025-01-08 17:24:54 CLIENT -> SERVER:
2025-01-08 17:24:54 CLIENT -> SERVER: This is the body in plain text for non-HTML mail clients
2025-01-08 17:24:54 CLIENT -> SERVER:
2025-01-08 17:24:54 CLIENT -> SERVER: --b1=_hTX5faPZ0GNL7dgpuJaQTDEPmxJrAXJ8L71qgkz9Ow
2025-01-08 17:24:54 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2025-01-08 17:24:54 CLIENT -> SERVER:
2025-01-08 17:24:54 CLIENT -> SERVER: This is the HTML message body <b>in bold!</b>
2025-01-08 17:24:54 CLIENT -> SERVER:
2025-01-08 17:24:54 CLIENT -> SERVER:
2025-01-08 17:24:54 CLIENT -> SERVER: --b1=_hTX5faPZ0GNL7dgpuJaQTDEPmxJrAXJ8L71qgkz9Ow--
2025-01-08 17:24:54 CLIENT -> SERVER:
2025-01-08 17:24:54 CLIENT -> SERVER: .
2025-01-08 17:24:54 SERVER -> CLIENT: 250 OK id=1tVZna-00000009Nxn-0N4F
2025-01-08 17:24:54 CLIENT -> SERVER: QUIT
2025-01-08 17:24:54 SERVER -> CLIENT: 221 server2.uk.gethosted.online closing connection
Message has been sent
 
For clarity, I am using SMTP with an operational email account and it can send locally but not remotely.
Have you tried sending to mail-tester.com as suggested?
Because smtp with operational e-mail account does log in /var/log/exim and phpmailers log in the php mail log which is normally to be found under the user using the php mailer or better said in the /home/username/.php directory you would find the logfiles.

This part of the log is from a phpmailer.
If you just use real smtp, so via mail client, not via phpmailer script, can you send outgoing mail this way?

Other than that I can't be of help without unmasked information. If you don't want to post publicly, you can send it to me via pm.

Also see this:
Code:
2025-01-08 17:24:54 CLIENT -> SERVER: From: ***** <support@*****.com>
2025-01-08 17:24:54 CLIENT -> SERVER: Reply-To: ***** NO-REPLY <no-reply@*****.com>
in most cases it's not possible to reply to a no-reply@ mail address...
 
I just got your notification I was preparing another post, yes that's exactly the stage I am at.

I've checked the mx, txt and done some manual telnet operations etc but thus far only mail-tester.com has thrown something obvious up. My score was 2.5, so will be working on that.
 

Attachments

  • Screenshot 2025-01-08 at 18.31.30.png
    Screenshot 2025-01-08 at 18.31.30.png
    50.4 KB · Views: 4
Ah yes, for sending mail to Gmail (also others but for sure this one) the SPF record must be in good order and using DKIM is also advisable (if possible).
Hope you can fix things, for mail-tester you should at least (minimal) be able to reach 9/10 if all is configured correctly.
If you run into other issues which prevents you from getting this score, just let us know.
 
Back
Top