Skip to content

Commit

Permalink
Merge pull request #148 from hexathos/master
Browse files Browse the repository at this point in the history
Added Header Data
  • Loading branch information
barbushin authored Jul 18, 2016
2 parents a0f3323 + c557036 commit 6378f19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/PhpImap/IncomingMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class IncomingMail {

public $id;
public $date;
public $headersRaw;
public $headers;
public $subject;

public $fromName;
Expand Down
11 changes: 7 additions & 4 deletions src/PhpImap/Mailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function deleteMail($mailId) {
public function moveMail($mailId, $mailBox) {
return imap_mail_move($this->getImapStream(), $mailId, $mailBox, CP_UID) && $this->expungeDeletedMails();
}

/**
* Copys mails listed in mailId into new mailbox
* @return bool
Expand Down Expand Up @@ -402,7 +402,7 @@ public function getQuotaUsage() {
}
return $quota;
}

/**
* Get raw mail data
*
Expand All @@ -415,7 +415,7 @@ public function getRawMail($msgId, $markAsSeen = true){
if(!$markAsSeen) {
$options |= FT_PEEK;
}

return imap_fetchbody($this->getImapStream(), $msgId, '', $options);
}

Expand All @@ -427,9 +427,12 @@ public function getRawMail($msgId, $markAsSeen = true){
* @return IncomingMail
*/
public function getMail($mailId, $markAsSeen = true) {
$head = imap_rfc822_parse_headers(imap_fetchheader($this->getImapStream(), $mailId, FT_UID));
$headersRaw = imap_fetchheader($this->getImapStream(), $mailId, FT_UID);
$head = imap_rfc822_parse_headers($headersRaw);

$mail = new IncomingMail();
$mail->headersRaw = $headersRaw;
$mail->headers = $head;
$mail->id = $mailId;
$mail->date = date('Y-m-d H:i:s', isset($head->date) ? strtotime(preg_replace('/\(.*?\)/', '', $head->date)) : time());
$mail->subject = isset($head->subject) ? $this->decodeMimeStr($head->subject, $this->serverEncoding) : null;
Expand Down

0 comments on commit 6378f19

Please sign in to comment.