PHP Mail working on one server, not another?

Rayj00

New member
So I have a test environment (Ubuntu) on one server hosted by Linode.
I have a production server (Ubuntu) hosted by SSD-Nodes.

I have an html form that is saved in a mysql db. I also send a copy of
the form to the originator as well as the owner of the website.

It works fine on the test server, so I basically ported the associated code
to the production server.

I am using msmtp for my MTA. Version 1.8.6 on test server and v 1.8.16 on production.

php.ini:
sendmail_path = "/usr/bin/msmtp -C /etc/msmtprc --logfile /var/log/msmtp.log -a gmail -t"

msmtprc:
account gmail
tls on
auth on
host smtp.gmail.com
port 587
user OLSorderform@gmail.com
from OLSorderform@gmail.com
password xxxx xxxx xxxx xxxx
(password obfuscated)

I have 2-factor w/App password set for the gmail account.

It works fine on the test server, but somewhere it's failing on the production server?
I have the same config (php and the msmtprc) on both servers.

On the test server, I am using PHP 7.4 and 8.1 on the production, if that matters.
I'm not seeing any error indicators in the mail.err or mail.log files, nor the msmtprc.log.

As this production server is on a provider I have never used before, could they be stopping
gmail from php as I have read is happening with some providers to stop spam?

Any other idea how I can find exactly where this is failing?

Thanks and let me know if you need more info.

Ray
 
So, the /usr/bin/msmtp file owner ship was root:root. On the test server it is www-data:root.
I changed the production server to www-data:root and voila! Does that make sense?

Ray
 
It's plausible that the production server's hosting provider imposes restrictions on outgoing SMTP connections to prevent spam. Verify firewall settings for port 587 and test connectivity to Gmail's SMTP server using telnet or netcat. Ensure the production server has internet access and check for any security blocks on the Gmail account.

Best Regard
Danish Hafeez | QA Assistant
 
Last edited by a moderator:
Back
Top