Mail function in php, developers wants painless coding with email functionality .
we can still use remote smtp mail server with php mail function as below
# Install ssmtp
yum install ssmtp
# configure ssmtp
/etc/ssmtp/ssmtp.conf
root=noreply@testdomain.com
mailhub=myauthsmtp.com:2525
rewriteDomain=testdomain.com
hostname=myauthsmtp.com:2525
## ssl enabled with smtp then
UseSTARTTLS=YES
AuthUser=username
AuthPass=password
FromLineOverride=YES
# php.ini
replace
mailcmd=/usr/sbin/sendmail -t
with
mailcmd=ssmtp -t
# Another option stop/remove sendmail and replace it with ssmtp no need to change in php.ini
sudo service sendmail stop
sudo chkconfig --levels 2345 sendmail off
# links as below
sudo mv /usr/sbin/sendmail /usr/sbin/sendmail.orig
sudo ln -s /usr/bin/ssmtp/sbin/ssmtp /usr/sbin/sendmail
Note: system services will use default sendmail so always keep into account FROM addresses root@yourdomain.com must not be configured in order to avoid smtp account suspension .
No comments:
Post a Comment