toggle menu

PHP mail() function not working on digitalocean

Sanjay Kumar |29 Mar at 04:03

I have installed Postfix as per suggestion (on DigitalOcean) for PHP mail(), But its not working.
i have just create droplet and setup LEMP and all postfix steps executed without any issues, but not working mail.
$to      = 'youremail@email.com';
$subject = 'mail subject';
$message = 'Mail Body';
$headers = 'From: info@email.com' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers)){
    echo "done";
}else{
    echo "not sent";
}
?>

Run with ip address like (dummy ip) : http://122.21.23.21/emailfile.php
executed url and seems mail sent. But not getting mail.

Pleae any one have idea about this please suggest.

  • 2 likes
  • 4 comments

Dhanavi07 Apr at 08:04

Maybe, mail is going to spam.

vibhu09 Apr at 08:04

how to fix

vibhu09 Apr at 08:04

how to fix

vibhu09 Apr at 08:04

how to fix

Posted:

29 Mar at 04:03

Viewed:

2685 times

Active:

20 Jun at 08:06