简体   繁体   English

HTML电子邮件作为文件附件

[英]HTML E-Mail as fileattachment

I have a Problem with Outlook 2010. I sent an E-Mail with a Contactform with this Code: 我在使用Outlook 2010时遇到问题。我使用以下代码发送了带有Contactform的电子邮件:

  $message = '
        <html>
            <head>
            <title>Anfrage ('.$cfg->get('global.page.title').')</title>
            <style type="text/css">
                body { background:#FFFFFF; color:#000000; }
                #tbl td {
                    background:#F0F0F0;
                    vertical-align:top;
                }
                #tbl2 td {
                    background:#E0E0E0;
                    vertical-align:top;
                }
            </style>
        </head>
        <body>
            <p>Mail von der Webseite '.$cfg->get('global.page.title').'</p>
            <table id="tbl">
            <tr>
                <td>Absender</td>
                <td>'.htmlspecialchars($_POST['name']).' ('.htmlspecialchars(trim($_POST['email'])).')</td>
            </tr>
            <tr id="tbl2">
                <td>Betreff:</td>
                <td>'.htmlspecialchars($_POST["topic"]).'</td>
            </tr>
            <tr>
                <td>Nachricht:</td>
                <td>'.nl2br(htmlspecialchars($_POST["message"])).'</td>
            </tr>
            </table>
        </body>
        </html>';

        $absender = $_POST['name'].' <'.$_POST['email'].'>';
        $header  = "From: $absender\n";
        $header .= "Reply-To: $absender\n";
        $header .= "X-Mailer: PHP/" . phpversion(). "\n";
        $header .= "X-Sender-IP: " . $_SERVER["REMOTE_ADDR"] . "\n";
        $header .= "Content-Type: text/html; Charset=utf-8";
        $send_mail = mail($cfg->get('contact.toMailAdress'), "Anfrage (".$cfg->get('global.page.title').")", $message, $header);
  //$send_mail = mail("jonathan.sigg@studcom.ch", "Anfrage (".$cfg->get('global.page.title').")", $message, $header);
        $_SESSION['kontakt_form_time'] = time();
        $tpl->assign("mail_sent", $send_mail);

When I sent the email, doesn't shows the message. 当我发送电子邮件时,不显示消息。 it generates a File named [NAME].h . 它会生成一个名为[NAME].h的文件。 The Message is in this File. 消息在此文件中。 How can I fix that, that the message shows in the E-Mail. 我该如何解决,该消息显示在电子邮件中。 Is this a Problem about the settings in Outlook? 这是有关Outlook中设置的问题吗?

The problem is with your security settings in Outlook. 问题出在Outlook中的安全设置。 You need to change the settings to display HTML. 您需要更改设置以显示HTML。

Be careful though, other people trying to read this message will have the same problem. 但是请小心,其他尝试阅读此消息的人也会遇到相同的问题。 It's common courtesy to offer a plain text version in addition to a HTML version so those that receive these emails don't have to compromise their security settings for you. 除HTML版本外,还提供纯文本版本是正常的礼貌,因此接收这些电子邮件的人不必为您破坏其安全设置。 There's a good chance messages like this can be marked as Spam too. 这样的邮件也很有可能也被标记为垃圾邮件。

Good luck. 祝好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM