我如何发送电子邮件通知给我的用户谁在我的表单使用php注册详情?
我有代码运行完美的电子邮件给我,但现在我也想我的用户相同的细节。
我试图使用"$from"到我的数组"$to",但没有收到电子邮件。
我的<<p> strong> mail.php<?php
$subject = "Email Notification";
$message = "Thank you for your email";
$message = "Your Registering details are as follows:";
$message .= "<br><br>";
$message .= "<table border='1'>";
$message .= "<tr><td>Name</td><td>".$_POST['name']."</td></tr>";
$message .= "<tr><td>Email</td><td>".$_POST['email']."</td></tr>";
$message .= "</table>";
$from = $_POST['email'];
$to = array('my_address@example.com', 'my_address2@example.com', $from);
$lp = "notification@example.com";
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=utf-8rn";
$headers .= 'from: '.$lp .'' . "rn" .
'Reply-To: '.$lp.'' . "rn" .
'X-Mailer: PHP/' . phpversion();
foreach($to as $row)
{
mail($row,$subject,$message,$headers);
}
echo "Mail Sent.";
die;
?>
在共享主机上,您需要从"现有电子邮件"发送电子邮件,至少要匹配域名,这是很常见的。也许这就是邮件没有发送的原因?
例如,如果你的域名是"www.my-awesome-domain.com",你就不能发送邮件头
"from: example@example.com"
相反,确保从你的域名发送电子邮件,最好是一个现有的电子邮箱,例如:
"from: office@my-awesome-domain.com"
希望有帮助!:)