@@ -104,6 +104,7 @@ class Message {
104104 * @var string $in_reply_to
105105 * @var array $sender
106106 * @var array $flags
107+ * @var array $priority
107108 */
108109 public $ message_id = '' ;
109110 public $ message_no = null ;
@@ -117,6 +118,7 @@ class Message {
117118 public $ reply_to = [];
118119 public $ in_reply_to = '' ;
119120 public $ sender = [];
121+ public $ priority = 0 ;
120122
121123 /**
122124 * Message body components
@@ -152,6 +154,13 @@ class Message {
152154 const ENC_QUOTED_PRINTABLE = 4 ;
153155 const ENC_OTHER = 5 ;
154156
157+ const PRIORITY_UNKNOWN = 0 ;
158+ const PRIORITY_HIGHEST = 1 ;
159+ const PRIORITY_HIGH = 2 ;
160+ const PRIORITY_NORMAL = 3 ;
161+ const PRIORITY_LOW = 4 ;
162+ const PRIORITY_LOWEST = 5 ;
163+
155164 /**
156165 * Message constructor.
157166 *
@@ -279,6 +288,33 @@ private function parseHeader() {
279288 $ header = imap_rfc822_parse_headers ($ this ->header );
280289 }
281290
291+ if (preg_match ('/x\-priority\:.*([0-9]{1,2})/i ' , $ this ->header , $ priority )){
292+ $ priority = isset ($ priority [1 ]) ? (int ) $ priority [1 ] : 0 ;
293+ switch ($ priority ){
294+ case self ::PRIORITY_HIGHEST ;
295+ $ this ->priority = self ::PRIORITY_HIGHEST ;
296+ break ;
297+ case self ::PRIORITY_HIGH ;
298+ $ this ->priority = self ::PRIORITY_HIGH ;
299+ break ;
300+ case self ::PRIORITY_NORMAL ;
301+ $ this ->priority = self ::PRIORITY_NORMAL ;
302+ break ;
303+ case self ::PRIORITY_LOW ;
304+ $ this ->priority = self ::PRIORITY_LOW ;
305+ break ;
306+ case self ::PRIORITY_LOWEST ;
307+ $ this ->priority = self ::PRIORITY_LOWEST ;
308+ break ;
309+ default :
310+ $ this ->priority = self ::PRIORITY_UNKNOWN ;
311+ break ;
312+ }
313+ }
314+
315+ if (property_exists ($ header , 'subject ' )) {
316+ $ this ->subject = imap_utf8 ($ header ->subject );
317+ }
282318 if (property_exists ($ header , 'subject ' )) {
283319 $ this ->subject = imap_utf8 ($ header ->subject );
284320 }
@@ -835,6 +871,13 @@ public function getFetchBodyOption() {
835871 return $ this ->fetch_body ;
836872 }
837873
874+ /**
875+ * @return integer
876+ */
877+ public function getPriority () {
878+ return $ this ->priority ;
879+ }
880+
838881 /**
839882 * @return boolean
840883 */
0 commit comments