Wednesday 7 April 2021

Linux CentOS 7 PHP mail() function SMTP Settings

Had some changes in email setup and security levels. Since setting up OAuth2.0 is a little tricky decided to set up a separate Gmail account for sending mail from this server. 

Took my an hour to figure out how this was set up on this machine so this time decided to write it down here.

The PHP script uses "mail($email_address,$subject,$body, $header)", on our system this meant that means it uses the Linux mail binary. The SMTP settings for this are located here: /etc/mail/authinfo/casmtp-auth

I changed the one line in this file with this syntax:

AuthInfo: "U:root" "I:email@address.com" "P:password"

That was not all, next was:

makemap -r hash smtp-auth.db < smtp-auth

Then:

systemctl restart sendmail

No comments: