Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for double quotes in email subject #215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
28 changes: 26 additions & 2 deletions fMailbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -1256,8 +1256,32 @@ public function listMessages($limit=NULL, $page=NULL)
}

$output = array();
$response = $this->write('FETCH ' . $start . ':' . $end . ' (UID INTERNALDATE RFC822.SIZE ENVELOPE)');
foreach ($response as $line) {
//this will parse the {122122} literal in mail fetch command , which are created due to the presence of double quotes (") in email subjects, if both the mixed email subject are present , first email with double quotes in subject are proceeded and later the normal one
$response = $this -> write('FETCH ' . $start . ':' . $end . ' (UID INTERNALDATE RFC822.SIZE ENVELOPE)');
$hintter = implode(' ', $response);
$pattern = '(\{[0-9]+\})';

if (preg_match($pattern, $hintter, $match)) {

$responses = preg_replace($pattern, '', $response);
$responsesnew = array();
$i = 0;
$j = 0;
foreach ($responses as $reps) {

if (substr(trim($reps), 0, 1) != '*') {
$responsesnew[$i] = $responses[$j - 1] . $reps;
$i++;
}

$j++;

}
} else {
$responsesnew = $response;
}

foreach ($responsesnew as $line) {
if (preg_match('#^\s*\*\s+(\d+)\s+FETCH\s+\((.*)\)\s*$#', $line, $match)) {
$details = self::parseResponse($match[2], TRUE);
$info = array();
Expand Down