带有MIME版本的php电子邮件头:1.0

时间:2012-04-20 18:51:47

标签: php email header mime

我有这些代码行:

        $from = "email@domian.com";
        $headers = "From:" . $from;
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

我需要MIME类型,因为我使用file_get_contents作为html文件,我的问题是在显示为“email@domain.comMIME-Version:1.0”的标题下,我只想说“email @ domain”。 com“如何在标题中显示from?中取出MIME类型?

谢谢

2 个答案:

答案 0 :(得分:7)

只需在\r\n标题后添加From:

$headers = "From:" . $from . "\r\n";

答案 1 :(得分:0)

$to = "syedahsaan35@gmail.com";
$subject = "New Agent Record";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "Reply-To: New Agent Record <agent@pakvillaspro.com>\r\n"; 
$headers .= "Return-Path:New Agent Record <agent@pakvillaspro.com>\r\n";
$headers .= "From: New Agent Record <agent@pakvillaspro.com>\r\n";
$headers .= "Organization: New Agent Record\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";