accessing my gmail inbox via php code

后端 未结 5 1606
野趣味
野趣味 2020-12-28 19:14

how i can access my gmail account through my php code? I need to get the subject and the from address to from my gmail account.And then i need to mark the accessed as read o

5条回答
  •  囚心锁ツ
    2020-12-28 19:55

    I would just use the PHP imap functions and do something like this:

    subject;
        $from = $mail_headers->fromaddress;
        imap_setflag_full($mailbox, $mail[0], "\\Seen \\Flagged");
        imap_close($mailbox);
    ?>
    

    This connects to imap.googlemail.com (googlemail's imap server), sets $subject to the subject of the first message and $from to the from address of the first message. Then, it marks this message as read. (It's untested, but it should work :S)

提交回复
热议问题