By Roy Penrod
Hey,
I’m new to Digital Ocean and managing my own server.
Now that I’m comfortable with the Ubuntu 14.04 CLI, I’m going to set up a fresh LAMP installation.
Do I need to configure anything to get PHP’s mail function to work or should it work right from the new installation?
If there’s a guide that will help me, please link it for me.
Thanks for the help!
Roy
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Is there any update for this question? It no longer works… Have tried everything here and another dozen guides. Nothing works.
@jtittle thank you so much for your detail explication, despite everything I got stuck on the same error as you @RoyPenrod
-bash: export: `/usr/sbin/sendmail:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games': not a valid identifier
could you explain me how you had solve it? You said “I didn’t include PATH= before the path list.” but I still could not understand how to go over this issue.
@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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.