[英]Php Register Email Verification
我已经为我的网站整理了一份注册表格,该表格将使用电子邮件验证。 我想选择一个默认邮箱发送外发电子邮件。 如何在我的虚拟主机上指定发送外发电子邮件的邮箱?
if($result2){
$to = $email;
$subject = "Immo Registration Confirmation - $username";
$header = "Immo: Confirmation from Immo";
$message = "Thank you for registering at Immo Please click the link below to verify and activate your account. <br>";
$message .= "http://www.test.com/confirm.php?passkey=$confirmcode";
$sentmail = mail($to,$subject,$message,$header);
if($sentmail)
{
echo "Your Confirmation link Has Been Sent To Your Email Address.";
}
else
{
echo "Cannot send Confirmation link to your e-mail address";
}
}
电子邮件系统正在运行,我已经对其进行了测试,但是它来自的电子邮件地址是随机垃圾邮件,我想分配一个特定的邮箱进行注册。 如何做到这一点?
您需要正确设置“发件人”标题。 类似于下面的内容摘自文档http://php.net/manual/en/function.mail.php
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
您可以通过将发件人电子邮件添加到$ header变量中来定义发件人电子邮件。
$header .= 'From: from@mail.com \r\n';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.