I am having a problem sending emails when I add header information. However when I just remove the header parameter it works. What is wrong? Is it the code? Or some setting I need to change on the web server admin panel to say "Allow-Headers" or something? I am trying to send to hotmail in case this has any relavance in determining the problem. Any help would be greatly appreciated. Thanks.
Below Doesn't Send Email:
<?php
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]';
mail($to, $subject, $message, $headers);
?>
Below Sends Email:
<?php
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]';
mail($to, $subject, $message);
?>
\n
in the end of$headers
, but it's just a guess. – Petr R. Jun 16 at 15:32\r\n
to bothsubject
andheaders
should theoretically work. However, you should consider adding aFrom:...
in there (as part of your headers). Most email services/clients will most probably consider it as Spam, without it. – Fred Jun 16 at 15:37mail()
function has a lot of shortcomings. – Spudley Jun 16 at 15:42