PHP mail() - 如何设置优先级?

34 php email

有没有办法设置PHP mail()的优先级?我查看了在线手册,但我找不到任何参考.

优先级,我的意思是标题中的高,正常,低或1,2,3.所以收件人知道邮件的紧急程度.

谢谢!

tan*_*jir 59

这通常通过在标题中设置以下字段来完成:

  • "X-Priority"(值:从最高[1]到最低[5]的1到5),
  • "X-MSMail-Priority"(值:高,正常或低),
  • "重要性"(值:高,正常或低).

请参阅以下示例(摘自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);
?> 
Run Code Online (Sandbox Code Playgroud)

  • 不是"X-Priority:1(最高)".PHP_EOL? (2认同)
  • 是否有定义这些标头的规范?以及gmail / outlook / thunderbird /中的任何文档,其中显示了考虑了哪个标头的文档?[编辑]:我找到了一个指向RFC4021的https://www.iana.org/assignments/message-headers/message-headers.xhtml,但它指出标头是`Priority`而不是`X-Priority` (2认同)

Eva*_*ski 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); 
?>
Run Code Online (Sandbox Code Playgroud)

来自:http://www.php.net/manual/en/function.mail.php#91058