【问题标题】:Send an html email error content type or mime type发送 html 电子邮件错误内容类型或 mime 类型
【发布时间】:2013-08-29 14:05:07
【问题描述】:

我无法让这封电子邮件出现在 gmail 中。

代码以纯文本形式显示,所以我知道邮件服务器没有问题。但是我需要我的用户确认一个链接,但我无法让那些 html 元素出现。我已经尝试了从 mime 设置到内容类型的所有内容。

$to = $email; 
$from = "no-reply@alphaladys.com"; 
$subject = "Confirm Your Email"; 
$message = "<html><body>";
$message .= "
    <center> 
      <b>You are reiciving this email because you Signed up at Alphaladys.com</b> <br> 
      <font color=\"red\">Thank You, $name</font><br> 
      <b><a href=\"alphaladys.com/?71860c77c6745379b0d44304d66b6a13=emailVerify&key=$key\">Confirm Your Email</a></b><br>
    </center> 
    <br><br>© 2013 Copyright | AlphaLadys.Com |  All rights reserved.
"; 
$message .= "</body></html>";
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject , $message , $headers );

【问题讨论】:

  • 您在电子邮件中收到什么?
  • 消息以原始形式出现,html 代码以纯文本形式显示

标签: html email mime-types content-type


【解决方案1】:

我已经在我的虚拟主机中测试了这个示例,它运行良好:

<?php 

$from = "xxxxx@gmail.com"; 
$subject = "Confirm Your Email"; 
$message = "<html><body>";
$message .= "
    <center> 
      <b>You are reiciving this email because you Signed up at Alphaladys.com</b> <br> 
      <font color=\"red\">Thank You, $name</font><br> 
      <b><a href=\"alphaladys.com/?71860c77c6745379b0d44304d66b6a13=emailVerify&key=$key\">Confirm Your Email</a></b><br>
    </center> 
    <br><br>© 2013 Copyright | AlphaLadys.Com |  All rights reserved.
"; 
$message .= "</body></html>";
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
if(mail($from, $subject , $message , $headers )) echo 'Mail sent :)';
    else echo 'Mail not sent :(';}

?>

结果:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-01
    • 2012-12-26
    • 2011-05-30
    • 1970-01-01
    • 2011-07-22
    • 2023-03-10
    • 1970-01-01
    • 2021-01-17
    相关资源
    最近更新 更多