Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
Not receiving emails from php mail() function
I’m not receiving emails from mail() function.
I created a php test:
<?php ini_set( 'display_errors', 1 ); error_reporting( E_ALL ); $from = "email@example.com"; $to = "firstname.lastname@example.org"; $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…
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!
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.×