[英]Create Clickable verification link PHP mail
对于电子邮件验证,我为每个用户创建一个哈希,然后向用户发送验证电子邮件。邮件正文如下。
$message_body = '
Hello '.$first_name.',
Thank you for signing up!
Please click this link to activate your account:
http://www.alphaktu.co.in/verify.php?email='.$email.'&hash='.$hash ;
但我想将验证链接转换为可点击的链接。
首先,您可能希望在电子邮件正文中使用 HTML 链接,如下所示:
$message_body = '
Hello '.$first_name.',
Thank you for signing up!
Please click this link to activate your account:
<a href="http://www.alphaktu.co.in/verify.php?email='.$email.'&hash='.$hash.'">
Verification Link
</a>' ;
其次,要使其真正起作用,您需要在为电子邮件设置标题时使用 HTML MIME 类型。 如果你还没有,它看起来像这样:
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
这基本上告诉浏览器将带有消息正文的 HTML 代码解释为实际的 HTML,而不是纯文本。
对于电子邮件验证,我为每个用户创建一个哈希,然后向用户发送验证电子邮件。邮件正文如下所示。
$message_body = '
Hello '.$first_name.',
Thank you for signing up!
Please click this link to activate your account:
http://www.alphaktu.co.in/verify.php?email='.$email.'&hash='.$hash ;
但我想将验证链接转换为可点击链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.