通过IMAP检索电子邮件的附件


Retrieve attachments from email via 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连接很好,可以接收电子邮件,那么,我该如何让它检索这些电子邮件的附件呢?任何帮助将不胜感激!谢谢你

在stackoverflow上已经有很多这样的问题了。你试过搜索吗?

  • 提取PHP IMAP附件
  • PHP imap下载附件
  • 使用IMAP和PHP保存附件服务器