2012-10-02 44 views
-2

送我有PHP代码如何在PHP中添加HTML以HTML

但洽洽发送的文本模式

,我想编辑的消息与HTML模式下工作

这是我的contact.php的代码

<?php 
$webmaster_mail = '[email protected]'; 
$redirect_page = 'http://www.xxxx.com/'; 
$message_subject = 'msg'; 
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']); 
$in_Body =''; 
foreach($_POST as $in_k=>$in_v) { 
    $in_Body .="$in_k = $in_v\n\n"; 
} 
$in_Body .= 'IP: ' . $_SERVER['REMOTE_ADDR'] . "\n\n"; 
#$in_Body .= 'Host Name: ' . gethostbyaddr($_SERVER['REMOTE_ADDR']) . "\n\n"; //old get host name 
$in_Body .= 'Host Name: ' . $hostname . "\n\n"; 
$in_Body .= 'Browser: ' . $_SERVER['HTTP_USER_AGENT'] . "\n\n"; 
$in_Body .= 'Time: ' . $gmdate . "\n\n"; 
$in_Body .= 'Os: ' . getOS($_SERVER['HTTP_USER_AGENT']) . "\n\n"; 
#$in_Body .= 'country: ' . getCountry() . "\n\n"; 
$in_Body .= 'country: ' . $ip2c->get_country_name() . "\n\n"; 
mail(trim($webmaster_mail), "$message_subject ", "$in_Body","From: " . trim($webmaster_mail)); 
header("Location: $redirect_page"); 
//close(); 
?> 
+0

在电子邮件中添加表格和徽标时,请参阅msg –

+0

您想将其添加到您的问题吗?以及你遇到的具体问题的细节? – andrewsi

+0

不要建立你自己的哑剧电子邮件。使用[PHPMailer](http://phpmailer.worxware.com)或[Swiftmailer](http://swiftmailer.org)。它们使用起来更容易,并使得发送HTML邮件变得微不足道。 –

回答

1

你需要的,如果你要发送的邮件内容为html设置页眉

$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 

mail($to, $subject, $message, $headers); 
+0

THX templete但如何添加像

message
THX但如何添加像
message title

+0

阅读本http://css-tricks.com/sending-nice-html-email-with-php/ – GBD