How can I sent an mail with phpmailer with the option urgent set like in MS Outlook?
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
Supplement:
That work´s fine, but some SPAM Filter will use the Priority Configuration (doesn´t matters which Priority is set) to filter in SPAM.
And php Mailer will set the Priority Flag ALWAYS. (Default to 3)
So in MY php Mailer class i´d commentet the line
$this->HeaderLine('X-Priority', $this->Priority);
Maybe 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 configurable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With