【问题标题】:PHP HTML E-Mail Character IssuePHP HTML 电子邮件字符问题
【发布时间】:2010-01-28 07:16:51
【问题描述】:

每次我使用这个脚本时,我都会在电子邮件中出现随机符号。它是标题中的字符类型吗?如果是这样,正确的字符类型是什么?

    $icontent = nl2br($icontent);

    $str = "<html>";
    $str .= "<head>";
    $str .= "<title>Mail</title>";
    $str .= "<style type='text/css'>";
    $str .= "<!--";

    $str .= "body {";
    $str .= "   background-color:#FFFFFF;";
    $str .= "   margin:0px;";
    $str .= "   font-family:Arial;";
    $str .= "   padding:0px;";
    $str .= "}";

    $str .= "</style></head>";

    $str .= "<body>";
    $str .= "<center>";

    $str .= "<div class='logo'>";
    $str .= "<span style='font-size:12px'>$subject</span><br />";
    $str .= "<span style='font-size:10px; font-weight:normal'>" . date("d M Y H:i") . "</span><br />";
    $str .= "</div>";

    $str .= "<div class='content'>";
    $str .= $icontent;
    $str .= "</div>";

    $str .= "<div class='credit'>";
    $str .= "This e-mail is confidential.";
    $str .= "</div>";

    $str .= "</center>";
    $str .= "</body>";
    $str .= "</html>";

    $headers = "MIME-Version: 1.0rn"; 
    $headers .= "Content-type: text/html; charset=iso-8859-1rn"; 
    $headers = "From: Us <email@mydomain.com>\r\n";
    $headers .= "Content-type: text/html\r\n";

    mail($to, $subject, $str, $headers);

我将使用 Fedora 10 添加即时消息

提前致谢

【问题讨论】:

    标签: php html email


    【解决方案1】:
    $headers = "MIME-Version: 1.0\r\n"; // backslashes missing
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";  // backslashes missing
    $headers .= "From: Us <email@mydomain.com>\r\n"; // "." missing before "="
    $headers .= "Content-type: text/html\r\n";
    

    问题是您只发送了最后 2 个标头。

    【讨论】:

    • 哦,是的,刚刚看到解决了它:但不幸的是同样的问题:(
    【解决方案2】:
        $str .= "<head>";
        $str .= "<title>Mail</title>";
        $str .= "<style type='text/css'>";
    
    // This HTML comment is never closed:
        $str .= "<!--";
    
        $str .= "body {";
        $str .= "   background-color:#FFFFFF;";
        $str .= "   margin:0px;";
        $str .= "   font-family:Arial;";
        $str .= "   padding:0px;";
        $str .= "}";
    
    //    add this line:    
        $str .= "-->";
    
        $str .= "</style></head>";
    

    【讨论】:

    • 在那儿等它。它刚刚在复制和粘贴时被删除。加 1 发现良好
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-19
    • 2016-06-15
    • 1970-01-01
    • 2017-06-28
    • 1970-01-01
    相关资源
    最近更新 更多