Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added Header Data
According to #102 added header data, and raw data of them to IncomingMail.

Signed-off-by: Rainer Bendig <[email protected]>
  • Loading branch information
hexathos committed May 30, 2016
commit c557036478bf0ac910c143b9433d32392ecc4ce1
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