Set urgent option in phpmailer

How can I send mail with phpmailer with the option set urgently, as in MS Outlook?

+8
php phpmailer
source share
2 answers

This is done by adding headers of importance and priority to outgoing email. MS Outlook uses its own, while most other email clients use Importance or Priority . Add them using PHPMailer using the AddCustomHeader() method and the $Priority property.

 // For most clients expecting the Priority header: // 1 = High, 2 = Medium, 3 = Low $yourMessage->Priority = 1; // MS Outlook custom header // May set to "Urgent" or "Highest" rather than "High" $yourMessage->AddCustomHeader("X-MSMail-Priority: High"); // Not sure if Priority will also set the Importance header: $yourMessage->AddCustomHeader("Importance: High"); 

Please note that email clients may not fulfill / ignore these headers, so you cannot rely on them completely. In addition, many spam filters will use them as a red flag to identify spam. Use them with caution.

Official Documentation:

PHPMailer Properties

PHPMailer Methods

+21
source share

Addition:

This work is fine, but some SPAM filters will use the Priority Configuration (it doesn't matter what priority is set) to filter in SPAM.

And php Mailer will set the priority flag ALWAYS. (Default 3)

So, in MY php Mailer, the i'd class comments on the line

$this->HeaderLine('X-Priority', $this->Priority);

Perhaps a solution like:

class.phpmailer.php

if($this->Priority > 0) $this->HeaderLine('X-Priority', $this->Priority);

And in your php script something like this:

$yourMessage->Priority = 0;

Makes it a bit customizable.

0
source share

All Articles