我写了一个完美的代码,但我不明白为什么我的邮件不发送
$to = "info@domain.com";
$subject = "Account request from $first_name $last_name";
$emailBody = "
hi,
<br /><br />
<strong>First Name</strong> : $first_name.<br />
<strong>Last Name</strong> : $last_name.<br />
<strong>Phone</strong> : $phone.<br />
<strong>Email</strong> : $email.<br />
<strong>Message</strong> : $message.
";
// Email headers
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: domain' . "\r\n";
// Email Function
$mail = mail($to,$subject,$emailBody,$headers);
如果我签入条件
if($mail)
{
echo 'success';
}
else
{
echo 'fail';
}
在Localhost上它显示我成功但在线服务器上它显示我失败 - idont理解为什么????
答案 0 :(得分:1)
是的,我在From
上犯了一个错误首先我写这个
$headers .= 'From: domain' . "\r\n";
现在这是正确的
$headers .= 'From: Domain <info@domain.com>' . "\r\n";
对所有人来说,特别是“RiggsFolly”&amp; “山谷”