通过IMAP从电子邮件中检索附件?

时间:2013-04-29 15:09:11

标签: php imap

<?php
        $mailbox = "myServer";
        $user = "myUserName";
        $pass = "myPassWord";

        $connection = imap_open($mailbox, $user, $pass) or die ("Can't connect: " . imap_last_error());
        $list = imap_getmailboxes($connection, "myServer", "*");

        if(is_array($list)) {
            foreach($list as $key => $val) {
                echo "($key)";
                echo imap_utf7_decode($val->name) . ",";
                echo "'" . $val->delimiter . "',";
                echo $val->attributes . "<br />\n";
            }

        } else {
            echo "imap_getmailboxes failed: " . imap_last_error() . "\n";
        }            

        /* Search mailbox for unseen messages */
        $search = imap_search($connection, 'UNSEEN');

        $header = imap_headerinfo($connection, 1);
        $emailFrom =  $header->from[0]->mailbox . "@" . $header->from[0]->host;

        if($search) {
            echo $emailFrom;
        }


        /* Close the mailbox */
        imap_close($connection);
    ?>

这是我的代码...到目前为止,它通过IMAP完美连接并获取电子邮件,我将如何获取它来检索这些电子邮件的附件?任何帮助,将不胜感激!谢谢

1 个答案:

答案 0 :(得分:0)

已经有很多关于stackoverflow的qustion了。你试过搜索吗?