我正在使用html电子邮件模板通过电子邮件验证我的帐户
所以在我的“register_session.php”中我已经集成了PHPMailer和所有以便向用户发送电子邮件。我有以下代码:
$email = $_REQUEST['email']; //to
$subject = 'Account Verification';
$message = file_get_contents('../emailhtml.php', FILE_USE_INCLUDE_PATH);
$header = 'From:Test' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1\r\n'; //set FROM HEADER
mail ($email, $subject, $message, $header);
在$message
我使用file_get_contents
检索emailhtml.php
中的html代码。在emailhtml.php
内,我有我的html& css代码。见下文:
<?php
include("../web/Includes/database_master_mysql.php");
$database_master = new DatabaseMaster();
$email = $_GET['email'];
$code = $_GET['code'];
?>
<html>
<head></head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="50%" class="emailButton" style="background-color: #3498DB;">
<tr>
<td align="center" valign="middle" class="buttonContent" style="padding-top:15px;padding-bottom:15px;padding-right:15px;padding-left:15px;">
<a style="color:#FFFFFF;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:20px;line-height:135%;" href=" <?php echo'http://localhost/web/web/emailactivate.php?email='.$email.'&code='.$code.'';?> ">Confirmation</a>
</td>
</tr>
</table>
</body>
</html>
我没有放完所有代码,因为我关注的是我的href标签,我想在用户点击电子邮件中的按钮后重定向用户http://localhost/web/web/emailactivate.php?email='.$email.'&code='.$code.'
但我现在看到的是:
http://localhost/web/web/emailactivate.php?email%20=%3C?php%27.$email.%27?%3E&code=%3C?php%27.$code.%27%20?%3E
我对PHP并不是很了解,所以如果你能帮助我,那对我来说意味着一个世界。谢谢。
答案 0 :(得分:0)
首先,将php代码从您的emailhtml.php移到register_session.php,只留下html代码。
然后你的mail()函数将它放在一个变量中,以便你知道邮件是否被发送。
include("../web/Includes/database_master_mysql.php");
$database_master = new DatabaseMaster();
$email = $_GET['email'];
$code = $_GET['code'];
//$email = $_REQUEST['email']; //don't need this line. it's already set from the url request above.
$subject = 'Account Verification';
$message = file_get_contents('../emailhtml.php', FILE_USE_INCLUDE_PATH);
$header = 'From:Test' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1\r\n'; //set FROM HEADER
$send=mail ($email, $subject, $message, $header);
if($send){
//email was successfully sent, do something
} else {
//email did not send, check logs for errors
}