Custom IMAP command in php

2020-03-24 04:41发布

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

标签: php imap
3条回答
Ridiculous、
2楼-- · 2020-03-24 04:53

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

查看更多
再贱就再见
3楼-- · 2020-03-24 05:00

если собираетесь искать через 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

查看更多
淡お忘
4楼-- · 2020-03-24 05:04

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";
}
?>
查看更多
登录 后发表回答