By DeepakDO
Hi,
I am new to Digital Ocean and Linux admin in general. Trying to migrate my site from shared hosting to Digital Ocean.
Just created an “One Click LAMP on 14.04” droplet for my old Codeigniter 2 site. Have transferred the files and pointed the domain to given IP. Seems everything is fine for now.
I have a page with contact from, which uses a PHP mail() function.
Recently I found out that its not working on DO server (was working fine on my shared hosting).
When I submit the form, instead of mail sent feedback message, my form reloads.
Tried to check that in developer console and found out that I am not getting any AJAX response
Exact Message:
TypeError: response is null
After some googling, I figured out that PHP mail() is compiled to use sendmail by default and was not installed on my droplet instance.
Followed the instruections from here: https://www.digitalocean.com/community/questions/php-mail-function-enable
Did this:
$ sudo apt-get install sendmail mailutils sendmail-bin
$ sudo nano /etc/hosts
-> 127.0.1.1 <my.domain> <my.domain> {just replaced the droplet name with my domain}
-> 127.0.0.1 localhost localhost.localdomain <my.domain>
$ sudo sendmailconfig
-> answered 'y" to everything
I have php script to test this with sender, receiver, message. Whenever I try sending test mail, I get message
/home/<uername>/dead.letter... saved message in /home/<username>/dead.letter
Can’t figure out what’s going on.
Need some clues and suggestions.
Thanks!
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!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
I am able to send mail as current user for now. I tried this steps:
(1) Checked mail as current user using ‘mail’
$ mail
?quit
(2) Then turned off the machine
$sudo poweroff
(3) Then powered on the droplet from web interface
After that I am able to send mail
$ php mailtest.php //this is my script with sender, receiver etc.
However, the $sender field I set was ignored. When I received the mail. Its was sent as
<currently_logged_in_user>@domain
I am not really sure why I have to use ‘mail’ to make it work. After that I have “mbox” file in my home folder.
So far I am able to make it work. However my web contact form is still not working.
I am suspecting the permission issue.
I guess when mail is triggered from web form, sender is set as ‘www-data’, which doesn’t have proper permission to use sendmail.
So my question now is how to allow ‘www-data’ to use sendmail. I think once i figure that out, it should be fine.
Just found this and tried to follow what was suggested here but no luck http://stackoverflow.com/questions/23051612/what-is-the-proper-permission-configuration-of-sendmail
Any suggestion?
Thanks!
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.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
