简体   繁体   中英

HTML E-Mail as fileattachment

I have a Problem with Outlook 2010. I sent an E-Mail with a Contactform with this Code:

  $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 . 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?

The problem is with your security settings in Outlook. You need to change the settings to display 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. There's a good chance messages like this can be marked as Spam too.

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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