因此,当我提交表单时,一切都存储在数据库中就好了,我有一个非常简单的电子邮件,基本上包括,'嘿谢谢,这是你的链接'有点交易,我收到的就好了。但现在我已经升级为使用HTML正文而突然间我没有收到电子邮件,不知道为什么?
$to = $username;
$subject = 'Thanks for Registering on Dota Pub Stars!';
$message = '<html>
<head>
<title>Registration Successful!</title>
<link rel="stylesheet" src="http://www.sithhappens.net/css/style.css" />
</head>
<body class="bodybg">
<div id="registrationform">
<p class="success">Thanks for registering on Dota Pub Stars!</p>
<br />
<br />
<a class="button2" href="http://www.sithhappens.net/?key=' . $activation_key . '&username=' . $username . '&email=' . $email1 . '">Activate Account</a>
</div>
</body>
</html>';
$headers = "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: $from\r\n";
mail($to, $subject, $message, $headers);
答案 0 :(得分:1)
您的上述代码工作正常我检查这样尝试检查 $ username 值是电子邮件
我的例子
$to = 'rsharma@gmail.com';
$subject = 'Thanks for Registering on Dota Pub Stars!';
$message = '<html>
<head>
<title>Registration Successful!</title>
<link rel="stylesheet" src="http://site...net/css/style.css" />
</head>
<body class="bodybg">
<div id="registrationform">
<p class="success">Thanks for registering on Dota Pub Stars!</p>
<br />
<br />
<a class="button2" href="http://www.site...net/activateacc.php?key=345345&username=435345&email=34534534">Activate Account</a>
</div>
</body>
</html>';
$headers = "MIME-Version: 1.0 \r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: $from\r\n";
mail($to, $subject, $message, $headers);
还检查您的SMTP设置是否正常
答案 1 :(得分:0)
您的服务器可能是cAse-SEnSitive ...另外,添加From
$headers="From: $from\r\n";
$headers.="Content-Type: text/html;charset=iso-8859-1\n";
mail($to, $subject, $message, $headers);
答案 2 :(得分:0)
请从$结尾处删除尾随逗号','到
应为$to = $username;
并确保$ username是电子邮件地址
答案 3 :(得分:0)
您可以尝试按\n
而不是\r\n
分隔标题,不要混合它们,也不要在标题字符串的末尾包含一个标题。