当我使用mail()
功能时,它不起作用。我应该编辑什么才能让它发挥作用。
我尝试了多种代码组合,比如
<?php
$to = "myemail";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";
mail($to,$subject,$txt,$headers);
?>
即使是垃圾邮件文件夹也没有任何内容。
答案 0 :(得分:0)
您应该在代码中添加此内容
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <".$from. ">" ;
希望这会起作用
答案 1 :(得分:0)
尝试发送电子邮件而不传递任何标题信息。 只需使用至,主题和正文变量。
答案 2 :(得分:-2)
<?php
$regDate = "2013-02-14";
$today = date("Y-m-d");
$date = date("Y-m-d",strtotime("+1 year", strtotime($regDate)));
if($today == $date)
{
$to = "email";
$subject = "My subject";
$txt = "anything";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";
mail($to,$subject,$txt,$headers);
}
else
{
echo"no";
}
?>