我正在尝试使用该mail()
PHP
功能发送电子邮件。我让它工作,直到我试图给它一个“用户注册”的主题,然后邮件没有发送!
这是代码(大大简化了它)
$to = $this->post_data['register-email'];
$message = 'Hello etc';
$headers = 'From: noreply@example.com' . "\r\n" ;
$headers .= 'Content-type: text/html; chareset=iso-8859-1\r\n';
$headers .= 'From: Website <admin@example.com>';
mail($to, 'User Registration', $message, $headers);
我还尝试使用包含文本字符串的变量,但这不起作用。
为什么我添加主题例外时它不发送邮件?
谢谢
编辑:更新的代码仍然无法正常工作
$to = $this->post_data['register-email'];
$message = 'Hello etc';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= 'From: Website <admin@example.com>';
mail($to, 'User Registration', $message, $headers);