获取Gmail所有文件夹IMAP PHP [英] Get Gmail All folder IMAP PHP

查看:62
本文介绍了获取Gmail所有文件夹IMAP PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过imap访问gmail中的所有"文件夹.用不同的语言和名称.我该怎么办?

I want to access the All folder in gmail via imap. in different language and in different name. What should i do?

连接代码为:

$mail= imap_open('{imap.gmail.com:993/imap/ssl} //The all folder should be here ',$user,$pass);

推荐答案

这是我为该问题找到的解决方案.其想法是,全部"文件夹包含最大数量的邮件,因此我们必须获取其中的邮件数所有文件夹,然后找到最大的数字,即所有文件夹".

This is the solution i found for the problem.The idea is that the All folder contains the biggest number of mails so we have to get the number of mails in all the folders and then find the biggest number which is the All Folder.

当垃圾箱中的邮件数大于所有"文件夹时,此解决方案会出现问题.

This solution has a problem when the number of messages in trash is bigger than All folder.

    $mbox=imap_open("{imap.gmail.com:993/imap/ssl}", "user", "pass");
    $list = imap_getmailboxes($mbox, "{imap.gmail.com:993/imap/ssl}", "*");
    $mailbox=null;
    $mailbox_name='';
    $number=0;
    foreach ($list as $key ) {
        $con=imap_open("$key->name", "user", "pass");
        $number_msg=imap_num_msg($con);

            if($number_msg > $number)
            {
                $number = $number_msg;
                $mailbox= $con;
                $mailbox_name= $key->name;
            }

    }

这篇关于获取Gmail所有文件夹IMAP PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆