Question
PHP mail() function enable
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.
×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.
×@collinpatrickhenderson Thanks for your post, I followed it sort of..
Note: On Digital Ocean Ubuntu 14.04 LAMP image.
1) ran $ sendmail myemail@yahoo.com
This told me sendmail could be found in the following packages:
I decided to install the sendmail-bin. I believe this is all that is needed. For sending mail from form etc.
2) $ sudo apt-get install sendmail-bin
Then checked hosts file.
3) $ nano /etc/hosts
Looked like:
127.0.1.1 myhostname myhostname
127.0.0.1 localhost
4) control+x to quit nano
Then ran:
5) $ sudo sendmailconfig
Accepted Y to all choices. I think there was three or four..Once finished..
Tested again with:
6) $ sendmail myemail@yahoo.com
Test message
It worked nicely. Only thing now is I wonder how much more should be configured for security and performance, I did see a lot in that configuration.. Someone should do a tutorial on sendmail configuration???
hi please help me. in my droplet am installed easy engine and am installed postfix , sendmail and also am added sendmail path. but mail() function is not send the mail
The sendmail package doesn’t work with ubuntu 16.04.
It has some malware issue.
Even though i tried to remove it completely from ubuntu. it still uses the CPU (DISK I/O) almost upto 99%.
Works great. but have one issue. mail is received in spam folder, and send from address is www-data@dropletName
how do i solve that ?
hi am tried but mail not sending plz help me. am using nginx easyengine wordpress.. can i share my server details with you plz help me.
I’m not receiving emails from mail() function.
I created a php test:
<?php
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "info@crazytraction.com";
$to = "pabloezequiel@gmail.com";
$subject = "PHP Mail Test script";
$message = "This is a test to check the PHP Mail functionality";
$headers = "From:" . $from;
$headers .= "Reply-To: $to";
var_dump(mail($to,$subject,$message,$headers));
The output is…
bool(true)
I’m using a LEMP droplet on Ubuntu 16.06. I already installed postfix, opened port 25 and checked my host file…
127.0.0.1 localhost.crazytraction localhost amsterdam
which I think is correct (amsterdam is the hostname)
I can receive the email in one of my accounts, but I tried other 3 and none of them received the email, even Gmail is not receiving it.
What Am I doing wrong?
Btw, I tested to send an email using the same function on another droplet and it worked, so it has to be something with the environment, but I cannot figure what it is!
Thank you.
I spent hours tonight trying to figure out why sendmail and the php mail() function wouldn’t work on my DigitalOcean server. I followed all of the tutorials and couldn’t get anything to work. It turns out Gmail was blocking all of the mail coming from my DigitalOcean server. The mail I was sending couldn’t even make it to the spam folder. I discovered this by running sendmail from the command line. I then tried sending mail to a non-gmail account, and it worked just fine! So if anyone else is going through hell trying to figure this out, try sending some mail to a non-gmail account, or try running sendmail from the command line to see if you get some sort of error about Google / Gmail blocking your mail to prevent spam.
AND ONE MORE THING: The DigitalOcean server that was blocked by Gmail was not associated with a domain name, it simply had an IP address. I tried using sendmail and the php mail function on another DigitalOcean server of mine that is associated with a domain name, and that email was NOT BLOCKED. So if Gmail is blocking mail from your DigitalOcean server, it may be because your server isn’t associated with a domain name.