PHP mail function, remove the neccessity for errors-to header
I'm on a server that requires the errrors-to header to be set when using PHP mail() function. Popular applications such as Wordpress don't specify this header (at least not everywhere) - so the email isn't sent (instead I'm sent a mess开发者_如何学Pythonage saying there was an error sending the email because it lacked the header). The server host says this is not something they can change for the system. I do not have access to the .ini file. Is there something I can do about it?
yes, by setting the mail-header you need with the normal mail()-function:
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'errors-to: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
In wordpress, you can overload the wp_mail()-function to include that header.
精彩评论