Set urgent option in phpmailer

Muiter picture Muiter · May 26, 2012 · Viewed 14.8k times · Source

How can I sent an mail with phpmailer with the option urgent set like in MS Outlook?

Answer

Michael Berkowski picture Michael Berkowski · May 26, 2012

This is done by adding importance and priority headers to the outbound email. MS Outlook uses a particular one of its own, while most other mail clients use Importance or Priority. Add them with PHPMailer via 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");

Note that mail clients are free to not implement/ignore these headers, so you can't fully rely on them. Also, many spam filters will use them as a red flag for identifying spam. Use them with caution.

Official documentation:

PHPMailer Properties

PHPMailer Methods