4

What is alternative of java imap function doCommand in php ?

I want to fire some custom imap extension command but I don't find any function to do that here: http://php.net/manual/en/book.imap.php

deceze
  • 510,633
  • 85
  • 743
  • 889
Vivek Goel
  • 22,942
  • 29
  • 114
  • 186

3 Answers3

4

I have switched to zend imap. it supports custom command and fetch.

which solved my problem.

<?php
require_once 'Zend/Mail/Storage/Imap.php';
require_once "Zend/Mail/Protocol/Imap.php";
require_once "Zend/Registry.php";
$protocol = new Zend_Mail_Protocol_Imap('imap.gmail.com', 993, true);
$protocol->login($user, $pass);
$protocol->select('INBOX');
$storage = new Zend_Mail_Storage_Imap($protocol);
foreach ($storage as $messageId => $message) {
  $id = $protocol->fetch('Custom Attribute', $storage->getUniqueId($messageId));
  echo "Mail from '{$message->from}': {$message->subject} : Custom Attribute $id \n";
}
?>
Vivek Goel
  • 22,942
  • 29
  • 114
  • 186
  • 1
    The 3rd true parameter doesn't work (anymore?). I can connect succesfully using this: `$protocol = new \Zend\Mail\Protocol\Imap('imap.gmail.com', 993, 'SSL');` – RJR May 30 '15 at 02:14
0

Zend supports custom commends, but unfortunately does not support some basic ones like getting message parts that the default PHP imap library does... :-(

Andris
  • 4,392
  • 2
  • 20
  • 16
-1

если собираетесь искать через imap кириллические слова - у меня получилось так:

if you are going to search with IMAP non english characters - do like this:

$protocol->search(array("charset utf-8 X-GM-RAW", "Денис|test"));//это zend

т.е. в итоге запрос серверу будет такой:

a result of this request to the server will be:

. search charset utf-8 text Живалов|test

или так - используем imap расширение gmail мощный поиск:

or so - use gmail imap extension powerful search:

. search charset utf-8 X-GM-RAW 'Живалов'|'test'- вот так работает это апостроф на букве (Ё/тильде ~) именно в такой последовательности ни двойные кавычки, ни одинарные не работают, нуу вроде как и без всего работает:

it works, ' this apostrophe to the letter (e / ~ tilde) in that order either double quotes or single quotes do not work, sort of like without all the work:

. search charset utf-8 X-GM-RAW Живалов|test

I don't know how to post here some wiki, so you can reed something here

Shkur
  • 379
  • 3
  • 10