PHP包装类,用于常用的php-imap函数。

dev-master 2015-04-20 10:07 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:59:56 UTC


README

PHP包装类,用于常用的php-imap函数。

如何使用

连接到IMAP服务器

$imap_server = 'imap.yandex.ru';
$imap_user = 'chupakabra48';
$imap_password = 'MySuperP@ssw0rd';
$imap_port = 993;
$imap_ssl = true;
$imap_folder = "INBOX";

$t = new Imap($imap_server, $imap_user, $imap_password, $imap_port, $imap_ssl, $imap_folder);

返回包含最近、未读和总邮件数的关联数组

$t->getInboxInformation()

返回包含每封邮件主题以及每封邮件的Message Id的关联数组。

$t->getMessageIds());

给定新的$host、$user、$pass、$port、$ssl、$folder输入,此函数将断开旧连接并打开到指定服务器的新的连接。

为了示例,我使用相同的信息。

$t->changeLoginInfo($host, $user, $pass, $port, $ssl, $folder);

返回包含特定Message Id的详细信息的关联数组。

$t->getDetailedMessageInfo(2));

解析给定的电子邮件地址,并返回包含邮箱、主机和电子邮件地址名称的数组。

$a = $t->getDetailedMessageInfo(2);
$t->parseAddresses($a["reply"]));

生成符合RFC822规范的电子邮件地址。

$u = "testusername";
$h = "samplehost.com";
$n = "TestFirst TestLastName";
echo $t->createAddress($u, $h, $n);

删除匹配给定Message Id的邮件。

$t->deleteMessage(2);

返回包含给定Message Id的结构信息的数组。

@see imap_fetchstructure (https://php.ac.cn/manual/en/function.imap-fetchstructure.php)

print_r($t->getStructure(2));

返回给定Message Id的正文类型。

echo $t->getBodyType(2);

返回给定Message Id的编码类型。

echo $t->getEncodingType(2);

给定编码的Base64消息,返回解码后的文本。

编码的字符串读取:"Testing One Two Three"

echo $t->decodeBase64("VGVzdGluZyBPbmUgVHdvIFRocmVl");

给定新的文件夹,将断开并重新连接到指定的文件夹名称。

$t->changeFolder("NEW_FOLDER_NAME");

断开活跃的imap连接

$t->disconnect();