0

I have a php script that is only sending mail when the user registration. I put in something along the lines of:

$to ='testmail@gmail.com';
$message  = 'Hello';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: Website <admin@example.com>\r\n";
if($results= mail($to, 'User Registration', 'Test', $headers)) {
  echo 'success';
} else {
  echo 'fail';
}

But the email doesn't send on server. When i put the following line :

$headers .= "From: Website <admin@example.com>\r\n";

Why is this happening?

Qiu
  • 5,651
  • 10
  • 49
  • 56
Jayakrishnan K
  • 267
  • 2
  • 6

1 Answers1

0

Have you looked at the answer to smtp configuration for php mail it's very similar a question to yours?

Community
  • 1
  • 1
Peter Fox
  • 1,809
  • 2
  • 20
  • 34