Php 注册邮箱验证
Php Register Email Verification
我已经为我的网站准备了一张注册表,它将使用电子邮件验证。我想 select 一个默认邮箱来发送外发电子邮件。我如何指定我的虚拟主机上的哪个邮箱将发送外发电子邮件?
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";
}
}
电子邮件系统正在运行,我已经对其进行了测试,但是它来自的电子邮件地址是随机垃圾邮件,我想分配一个特定的邮箱进行注册。如何实现?
您需要正确设置'From' header。类似下面的内容取自文档 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';
我已经为我的网站准备了一张注册表,它将使用电子邮件验证。我想 select 一个默认邮箱来发送外发电子邮件。我如何指定我的虚拟主机上的哪个邮箱将发送外发电子邮件?
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";
}
}
电子邮件系统正在运行,我已经对其进行了测试,但是它来自的电子邮件地址是随机垃圾邮件,我想分配一个特定的邮箱进行注册。如何实现?
您需要正确设置'From' header。类似下面的内容取自文档 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';