发送HTML邮件给出原始的HTML [英] Sending html email gives raw html

查看:163
本文介绍了发送HTML邮件给出原始的HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP的电子邮件发送问题。
我正在运行以下代码:

I've got a problem with php html emailing. I've got the folowing code running:

<?php
$to = $_POST['username'];
$subject = "Uw account is successvol aangemaakt!";

//begin body message
$body = '<html><body><font face="verdana"><font color="#C0C0C0">Bedankt voor uw registratie op DirectOfficeSupport.com,Uw account is successvol aangemaakt!</font></html></body>';
$body .= '<html><body><p>&nbsp;</p></html></body>';
$body .= '<html><body><font color="#C0C0C0">Met een account worden alle functies van de website beschikbaar voor u.<font></html></body>';
$body .= '<html><body><p>&nbsp;</p></html></body>';
$body .= '<html><body><p>&nbsp;</p></html></body>';
$body .= '<html><body>Om uw account to kunnen gebruiken heeft u deze unieke verivicatie code gekregen. Deze moet ingevuld worden met het E-Mail adres en Wachtwoord. <font color="#C0C0C0">Les hier meer over verivicatie codes</font></html></body>';
$body .= '<html><body>Uw unieke verivicatie code: <b>!code!</b></html></body>';
$body .= '<html><body><p>&nbsp;</p></html></body>';
$body .= '<html><body><b>De informatie die u heeft opgegeven:</b></html></body>';
$body .= '<html><body>!1!</html></body>';

//end body message
 $from = 'account@directofficesupport.com';
 (mail($to, $subject, $body, $form)) 
 ?>

我尝试在电子邮件中显示它。但它唯一做的就是给我
原始代码。

I try to display it in the email. But the only thing it does is giving me the raw code.

推荐答案

您需要发送适当的头文件来显示HTML内容,它会停止你的原始代码,使用以下头文件:

You need to send proper headers to show the HTML content, it will stop your raw code, use the following headers

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: <account@directofficesupport.com>' . "\r\n";
mail($to, $subject, $body, $headers);

这篇关于发送HTML邮件给出原始的HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆