Today we were working on a web application that needed to dispatch several emails to users using the PHP mail function. The client requested that these emails have a priority set indicating to customers that they needed to be addressed immediately. If you are unfamiliar with email priority it is usually represented by an exclamation symbol, often red, that displays next to the message in your email client.
At first we weren’t quite sure how to achieve this, however, with some experimentation we put together the following solution that seems to work in all common email clients:
//BUILD EMAIL HEADERS $headers = "From: Some Person <firstname.lastname@example.org>n"; $headers .= "Reply-To: email@example.com"; $headers .= "Return-Path: firstname.lastname@example.org"; $headers .= "MIME-Version: 1.0n"; $headers .= "Content-Type: text/html; charset="iso-8859-1"n"; //SET EMAIL PRIORITY $headers .= "X-Priority: 1 (Highest)n"; $headers .= "X-MSMail-Priority: Highn"; $headers .= "Importance: Highn"; //SEND EMAIL mail("email@example.com","Subject","Body",$headers);