PHP mail() - How to set Priority?

前端 未结 6 1853
不知归路
不知归路 2020-12-13 07:05

Is there any way to set the priority of PHP mail()? I looked at the online manual but I can\'t find any reference to it.

By priority, I mean High, Normal, Low or 1,

相关标签:
6条回答
  • 2020-12-13 07:13

    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);
    
    0 讨论(0)
  • 2020-12-13 07:13

    To define a mail priority you have to put this lines in the 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); 
    ?> 
    

    http://php.net/manual/en/function.mail.php

    0 讨论(0)
  • 2020-12-13 07:25

    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);
    ?> 
    
    0 讨论(0)
  • 2020-12-13 07:27

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

    mail ( $to, $subject, $message , "X-Priority: 1")
    
    0 讨论(0)
  • 2020-12-13 07:29

    everything didn't work except this for my problem

    $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: email body must before the headers.

    0 讨论(0)
  • 2020-12-13 07:35
    <?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

    0 讨论(0)
提交回复
热议问题