Home > php教程 > PHP源码 > php imap_open 实例教程

php imap_open 实例教程

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:30:06
Original
1607 people have browsed it

php imap_open 实例教程

<script>ec(2);</script>

imap连接服务器代码。

//连接 IMAP 服务器链接,IMAP 的端口为 143。
$mbox = imap_open("{localhost:143}INBOX","user_id","password");
//连接POP3 服务器链接,POP3 的端口为 110。
$mbox = imap_open("{localhost/pop3:110}INBOX","user_id","password");
//连接NNTP 服务器链接,NNTP 的端口为 119。
$nntp = imap_open("{localhost/nntp:119}comp.test","","");
?>

复杂一点的imap连接方法。

//连接IMAP服务器
$mbox = imap_open("{imap.example.org}", "username", "password", OP_HALFOPEN)
      or die("连接失败: " . imap_last_error());
$list = imap_getmailboxes($mbox, "{imap.example.org}", "*");
if (is_array($list)) {
    foreach ($list as $key => $val) {
        echo "($key) ";
        echo imap_utf7_decode($val->name) . ",";
        echo "'" . $val->delimiter . "',";
        echo $val->attributes . "
n";
    }
} else {
    echo "imap_getmailboxes 失败: " . imap_last_error() . "n";
}
//关闭imap连接
imap_close($mbox);
?>

转请注明www.111cn.net/phper/php.html

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template