PHP-IMAP 函数可帮助您访问电子邮件帐户,IMAP 代表I互联网M艾尔A访问权限Protocol 使用这些函数您还可以使用 NNTP、POP3 协议和本地邮箱访问方法。
这个imap_check()函数接受一个表示 IMAP 流的资源值作为参数,验证有关给定邮箱的信息并以对象的形式返回它。
用法
imap_check($imap_stream);
参数
Sr.No | 参数及说明 |
---|---|
1 |
imap_stream (Mandatory) 这是一个表示 IMAP 流的字符串值,返回值imap_open()函数。 |
返回值
此函数返回一个对象,其中包含有关当前邮箱的信息,如果成功,则返回一个布尔值,如果失败则为 FALSE。
PHP版本
这个函数最初是在 PHP 版本 4 中引入的,并且适用于所有后续版本。
示例
下面的例子演示了imap_check()函数 -
<html>
<body>
<?php
//Establishing connection
$url = "{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX";
$id = "tutorialspoint.test@gmail.com";
$pwd = "cohondob_123";
$imap = imap_open($url, $id, $pwd);
print("Connection established...."."<br>");
//Fetching the contents of a message
print("Overview of the first message:"."<br>");
$obj = imap_check($imap);
print("<br>");
print("Date:".$obj->Date);
print("<br>");
print("Driver:".$obj−>Driver);
print("<br>");
print("Mailbox:".$obj−>Mailbox);
print("<br>");
print("Nmsgs:".$obj−>Nmsgs);
print("<br>");
print("Recent:".$obj−>Recent);
print("<br>");
//Closing the connection
imap_close($imap);
?>
</body>
</html>
这将生成以下输出 -
Connection established.... Overview of the first message: Date:Mon, 26 Oct 2020 11:38:26 +0530 (India Standard Time) Driver:imap Mailbox:{imap.gmail.com:993/imap/notls/ssl/novalidate-cert/user="tutorialspoint.test@gmail.com"}INBOX Nmsgs:6 Recent:0
示例
以下是此函数的另一个 -
<html>
<body>
<?php
//Establishing connection
$url = "{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX";
$id = "tutorialspoint.test@gmail.com";
$pwd = "cohondob_123";
$imap = imap_open($url, $id, $pwd);
print("Connection established...."."<br>");
//Fetching the contents of a message
print("Overview of the first message:"."<br>");
$MC = imap_check($imap);
$overview = imap_fetch_overview($imap, "1:{$MC->Nmsgs}");
foreach ($overview as $obj) {
print("<br>");
print_r($obj);
print("<br>");
}
//Closing the connection
imap_close($imap);
?>
</body>
</html>
输出
这将生成以下输出 -
Connection established.... Overview of the first message: stdClass Object ( [from] => Sender[to] => tutorialspoint.test@gmail.com [date] => Thu, 22 Oct 2020 20:10:17 +0530 [message_id] => [size] => 4857 [uid] => 19 [msgno] => 1 [recent] => 0 [flagged] => 0 [answered] => 0 [deleted] => 0 [seen] => 1 [draft] => 0 [udate] => 1603377656 ) stdClass Object ( [from] => Sender[to] => tutorialspoint.test@gmail.com [date] => Thu, 22 Oct 2020 20:10:52 +0530 [message_id] => [size] => 4858 [uid] => 20 [msgno] => 2 [recent] => 0 [flagged] => 0 [answered] => 0 [deleted] => 0 [seen] => 1 [draft] => 0 [udate] => 1603377691 ) stdClass Object ( [from] => Sender[to] => tutorialspoint.test@gmail.com [date] => Sun, 25 Oct 2020 16:11:22 +0530 [message_id] => [size] => 4880 [uid] => 42 [msgno] => 3 [recent] => 0 [flagged] => 0 [answered] => 0 [deleted] => 0 [seen] => 1 [draft] => 0 [udate] => 1603622523 ) stdClass Object ( [from] => Sender[to] => tutorialspoint.test@gmail.com [date] => Sun, 25 Oct 2020 17:22:41 +0530 [message_id] => [size] => 4882 [uid] => 49 [msgno] => 4 [recent] => 0 [flagged] => 0 [answered] => 0 [deleted] => 0 [seen] => 1 [draft] => 0 [udate] => 1603626802 ) stdClass Object ( [from] => Sender[to] => tutorialspoint.test@gmail.com [date] => Sun, 25 Oct 2020 17:23:10 +0530 [message_id] => [size] => 4884 [uid] => 50 [msgno] => 5 [recent] => 0 [flagged] => 0 [answered] => 0 [deleted] => 0 [seen] => 1 [draft] => 0 [udate] => 1603626831 ) stdClass Object ( [from] => Sender[to] => tutorialspoint.test@gmail.com [date] => Sun, 25 Oct 2020 17:24:25 +0530 [message_id] => [size] => 4883 [uid] => 51 [msgno] => 6 [recent] => 0 [flagged] => 0 [answered] => 0 [deleted] => 0 [seen] => 1 [draft] => 0 [udate] => 1603626906 )
相关用法
- PHP imap_createmailbox()用法及代码示例
- PHP imap_clearflag_full()用法及代码示例
- PHP imap_close()用法及代码示例
- PHP imap_create()用法及代码示例
- PHP imap_getsubscribed()用法及代码示例
- PHP imap_header()用法及代码示例
- PHP imap_last_error()用法及代码示例
- PHP imap_mutf7_to_utf8()用法及代码示例
- PHP imap_headerinfo()用法及代码示例
- PHP imap_lsub()用法及代码示例
- PHP imap_fetchtext()用法及代码示例
- PHP imap_listmailbox()用法及代码示例
- PHP imap_timeout()用法及代码示例
- PHP imap_num_msg()用法及代码示例
- PHP imap_undelete()用法及代码示例
- PHP imap_mail_move()用法及代码示例
- PHP imap_status()用法及代码示例
- PHP imap_utf8_to_mutf7()用法及代码示例
- PHP imap_base64()用法及代码示例
- PHP imap_listscan()用法及代码示例
注:本文由纯净天空筛选整理自 PHP - imap_check() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。