Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP mail() - How to set Priority?

Tags:

php

email

That's usually done by setting following fields in the header:

  • "X-Priority" (values: 1 to 5- from the highest[1] to lowest[5]),
  • "X-MSMail-Priority" (values: High, Normal, or Low),
  • "Importance" (values: High, Normal, or Low).

See the following example (taken from php's mail function documentation):

<?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);
?> 

<?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); 
?>

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


Call it with the X-Priority header in the 4th parameter:

mail ( $to, $subject, $message , "X-Priority: 1")

A comment on the PHP mail function documentation said:

<?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);