0

How can I set message priority in Sendmail queue?

I want all messages from PHP to be served first while I'm sending large news-list to subscribers "in background". Without priority definition urgent messages stuck in queue for a long time.

4

1 回答 1

0

You can use special "Precedence" mail header.

There are several predefined message classes: first-class, special-delivery, list, bulk, junk. First-class has the highest priority and junk has the lowest.

Other factors are message size and number of recipients.

priority = msgsize - (class * ClassFactor) + (nrcpt * RecipientFactor)

The lower is message priority, the faster it will be sent. ClassFactor and RecipientFactor are weights of these factors. You can change weights and classes in Sendmail config.

/* Low-priority mail */
$to      = 'customer@example.com';
$subject = 'subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'Precedence: bulk';

mail($to, $subject, $message, $headers);
于 2013-05-17T10:21:04.233 回答