@RoyPenrod - PHP’s mail()
function requires access to the sendmail
binary during compile time. If you use postfix
or another alternative, you’ll need to specify this when compiling as, by default, PHP will look for sendmail
and will throw an exception when compiling if it’s not available or an alternative has not been defined.
They also recommend that the path to the binary be available in your $PATH
. You can run echo $PATH
when logged in to the CLI to view what has been defined for the path variable. The output will look something like:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Of course, the above does not have the path to sendmail
defined, though you can add an export
to ~/.bashrc
which will be called the next time you login, or immediately if you run source ~/.bashrc
after saving the file.
You can add the path to sendmail
to ~/.bashrc
by running:
echo "" >> ~/.bashrc
echo "export /usr/sbin/sendmail:$PATH" >> ~/.bashrc
The first line simply adds a blank line to the end of your ~/.bashrc
file (I normally do this simply to keep things neatly spaced out). The last line adds the actual export
.
Wrapping it all together, you could simply do:
export SMAIL=$(which sendmail)
echo "" >> ~/.bashrc
echo "export $SMAIL:$PATH" >> ~/.bashrc
source ~/.bashrc
That’ll set SMAIL
to the path where the sendmail
binary is located (for the current session, which is all we need it for), add the blank line to the ~/.bashrc
file, add the export
to the ~/.bashrc
file ($SMAIL & $PATH will expand when echo'ed in to the file) and finally call the ~/.bashrc
file so that the changes take effect immediately.
@RoyPenrod I just came across this link and figured I’d pass it on: https://www.digitalocean.com/community/questions/php-mail-function-enable
Thanks for the link, King. I appreciate the help.