尝试将html添加到我的电子邮件中,但不会发送。
$users = $_POST['users'];
$check2 = mysql_query("SELECT * FROM users WHERE username='".$users."'");
while ($display = mysql_fetch_array($check2)) {
$id2 = $display['id'];
$name2 = $display['name'];
$username2 = $display['username'];
$email2 = $display['email'];
$subject2 = $_POST['subject'];
$message2 = $_POST['message'];
$from = "info@vcasts.tv";
$whofrom = "vCasts.tv";
$headers = "From: ". $whofrom . " <" . $from . ">\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8';
$mail_body = "Hey ".$username2.", ".$message2."<h2> hello </h2><div>Sent: ".date("l jS \of F Y ", time())."</div>";
mail($email2, $subject2, $mail_body, $headers) or die("");
echo "<div id='' style='overflow-y: scroll; height:400px;'>Your email has been sent to: $username2!</div>";
现在,如果我删除:
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8';
它会起作用,我做错了???
答案 0 :(得分:1)
吸烟枪 -
$headers = 'MIME-Version: 1.0' . "\r\n";
应该是
$headers .= 'MIME-Version: 1.0' . "\r\n";
答案 1 :(得分:0)
AlienWebguy是正确的。
另外,请尝试将您的邮件正文更改为:
$mail_body = "<html><body>Hey ".$username2.", ".$message2."<h2> hello </h2></body></html> Sent: ".date("l jS \of F Y ", time());
正确连接可确保它适用于所有Php版本。
答案 2 :(得分:0)
FIRST
$mail_body = "<html><body>Hey ".$username2.", ".$message2."<h2> hello </h2></body></html> Sent: ".date("l jS \of F Y ", time());
应该
$mail_body = "Hey ".$username2.", ".$message2."<h2> hello </h2><div>Sent: ".date("l jS \of F Y ", time())."</div>";
下一步
$check2 = mysql_query("SELECT * FROM users WHERE username='$_POST[users]'");
应该
$check2 = mysql_query("SELECT * FROM users WHERE username='".$users."'");
你应该加上这个权利
$users = $_POST['users']