0

I'm sending email using php header.

$to = 'test@email.com';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$message = '<h1>Test</h1>';

mail($to, $subject, $message, $headers);

This function is working properly.

But after I added "From" mail() function is not working.

$headers .= "From: from@address.com";

Any idea?

Jin
  • 924
  • 1
  • 9
  • 34

1 Answers1

0

May you are trying to spoof email, so it's getting failed.

It would be great practise to keep using Reply-To with From while using mail()

$headers .= "From: from@address.com\r\n";
$headers .= "Reply-To: from@address.com\r\n";

But, personally suggest you to use SMTP instead of mail() or PHPMailer.

Farhan
  • 253
  • 2
  • 9