Using PHP, How to search through Gmail's archived emails

前端 未结 2 1237
轮回少年
轮回少年 2021-02-05 05:44

(First time programming in PHP. Had some help. Need a bit more.)

Goal:

Pull the lastContactDate from a given email address from my gmail accou

2条回答
  •  南方客
    南方客 (楼主)
    2021-02-05 06:15

    Problem solved!

    Here's the solution. Using the original code above, we only modified the location in which our program searches. Instead of INBOX, it's:

        /* connect to gmail */
    $gmailhostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
    

    Specifically

    [Gmail]/All Mail
    

    Found the syntax here: http://php.net/manual/en/function.imap-delete.php

    But would not have been possible without Ben's epic solution below.. In large part for this bit:

        //You can find out what folders are available with this command:
    print_r(imap_list($conn, $gmailhostname, '*'));
    

    print_r listed all the folders in my account by name. We spotted "All Mail", in my case - 22,000+, found a sample piece of code on php.net with the syntax, plugged it in and viola!

    Thanks to mmmshuddup for cleaning my code and especially Ben for the enormous researching effort and leading solutions.

    This is fun as hell.

提交回复
热议问题