Reputation: 1041
I am using the following lib : https://github.com/vmuthal/VivOAuthIMAP
I would like to add a function call Search From that would enable me to search mails from a specific sender. Here's the additional function :
public function searchfrom($expeditor) {
$this->writeCommannd("A" . $this->codeCounter, " UID SEARCH FROM \"".$expeditor."\" ");
$response = $this->readResponse("A" . $this->codeCounter);
return $this->modifyResponse($response);
}
The result from the server is : "BAD" (nothing else).
Upvotes: 0
Views: 186
Reputation: 1015
/**
* Search in FROM ie. Email Address
* @param string $email
* @return Array
*/
public function searchFrom($email) {
$this->writeCommannd("A" . $this->codeCounter, "SEARCH FROM \"$email\"");
$response = $this->readResponse("A" . $this->codeCounter);
//Fetch by ids got in response
$ids = explode(" ", trim($response[0][1]));
unset($ids[0]);
unset($ids[1]);
$ids = array_values($ids);
$stringIds = implode(",",$ids);
$mails = $this->getMessage($stringIds);
return $mails;
}
I have added this to the Library. Check if it works for you. https://github.com/vmuthal/VivOAuthIMAP/blob/master/src/VivOAuthIMAP.php
Upvotes: 1