Monday, January 5, 2015

PHP mail issue

From CLI (server terminal) I could send mails using php
ie:
[root@ip-IP html]# php sendmail.php (It is working fine)
But when i try http://IP/sendmail.php mail won’t work.
I am using postfix, using a gmail account to relay mails.
In /var/log/maillog I can see the following
Jan 5 07:27:38 ip-ipaddress sSMTP[9847]: Creating SSL connection to host
Jan 5 07:27:38 ip-ipaddress sSMTP[9847]: SSL not working: unknown protocol (0)
Jan 5 07:27:38 ip-ipaddress sSMTP[9847]: Cannot open smtp.gmail.com:587
Jan 5 07:32:03 ip-ipaddress sSMTP[9850]: Creating SSL connection to host
Jan 5 07:32:03 ip-ipaddress sSMTP[9850]: SSL not working: unknown protocol (0)
Jan 5 07:32:03 ip-ipaddress sSMTP[9850]: Cannot open smtp.gmail.com:587
Jan 5 07:54:12 ip-ipaddress sSMTP[9893]: Creating SSL connection to host
Jan 5 07:54:12 ip-ipaddress sSMTP[9893]: SSL not working: unknown protocol (0)
Jan 5 07:54:12 ip-ipaddress sSMTP[9893]: Cannot open smtp.gmail.com:587
How I fix this issue:
vi /etc/php.ini
Edit sendmail_path to
sendmail_path = /usr/sbin/sendmail.postfix -t -i
/etc/init.d/httpd restart
This solved my issue.

http://skynetclouds.com/blog/cant-send-php-mail-using-browser-can-send-via-cli/

No comments:

Post a Comment