有没有办法设置PHP mail()的优先级?我查看了在线手册,但我找不到任何参考。
优先级,我的意思是标题中的高,正常,低或1,2,3。所以收件人知道邮件的紧急程度。
谢谢!
答案 0 :(得分:58)
通常通过在标题中设置以下字段来完成:
请参阅以下示例(摘自php的邮件功能文档):
<?php
$headers = "MIME-Version: 1.0\n" ;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "X-Priority: 1 (Highest)\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "Importance: High\n";
$status = mail($to, $subject, $message,$headers);
?>
答案 1 :(得分:7)
<?php
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "X-Priority: 1 (Highest)\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "Importance: High\n";
$status = mail($to, $subject, $message, $headers);
?>
答案 2 :(得分:2)
使用第4个参数中的X-Priority标头调用它:
mail ( $to, $subject, $message , "X-Priority: 1")
答案 3 :(得分:1)
<?php
$headers = "MIME-Version: 1.0\n" ;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "X-Priority: 1 (Highest)\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "Importance: High\n";
$status = mail($to, $subject, $message,$headers);
答案 4 :(得分:0)
要定义邮件优先级,您必须将这些行放在标题中:
<?php
$headers = "MIME-Version: 1.0\n" ;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$headers .= "X-Priority: 1 (Highest)\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "Importance: High\n";
$status = mail($to, $subject, $message,$headers);
?>
答案 5 :(得分:0)
除了我的问题之外,其他所有操作均不起作用
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: xyz@example.com' . "\r\n";
$headers .= 'Cc: Admin@example.com' . "\r\n";
PS:电子邮件正文必须在标题之前。