0

I am attempting to use PHP mail() to send an email with the From address changed. My example is below...

<?php

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Me <me@mydomain.com>' . "\r\n";

$message = 'Test Message';

mail("test@test.com","My subject",$message, $headers);

?>

No email is ever sent, if I remove the From address then the email gets sent fine.

Any ideas how to fix?

fightstarr20
  • 11,682
  • 40
  • 154
  • 278
  • 1
    Check your mail server logs. The destination is possibly rejecting the message because it detects a forged header. – Alex Howansky Apr 15 '14 at 19:32
  • Are you **sure** it's not getting sent? It may be getting spam-boxed, bounced (especially if you're sending to an AOL email), or silently ignored. (edit: so basically, what @AlexHowansky said.) – DimeCadmium Apr 15 '14 at 19:33
  • Additionally are you sending this from a local web server or something like a cPanel server? – Jono20201 Apr 15 '14 at 19:37
  • Check your Spambox, it's in there waiting for you; or, your HOST/ISP is blocking it. – Funk Forty Niner Apr 15 '14 at 19:40
  • If you are a Windows user this will not work as Windows does not come with a mail server like the nix's. You will have to use something line phpMailer or install a mail server like hMailer. – RiggsFolly Apr 15 '14 at 19:56

0 Answers0