download gmail attachements from php -
Can you please tell, how to download attachments from a Gmail account using PHP? Thanks
IMAP Solutions
/ * Connect to Gmail * / $ hostname = '{imap.gmail.com:993/imap/ssl}INBOX'; $ Username = 'davidwalshblog@gmail.com'; $ Password = 'David Walsh'; / * Try connecting * / $ inbox = imap_open (hostname, $ username, $ password) or die ('can not connect to Gmail:' .imap_last_error ()); / * Grab email * / $ email = imap_search ($ inbox, 'ALL'); / * If emails are returned, cycles through each ... * / ($ email) {/ * output var * / $ output = ''; Put the latest email on * * top * / rsort ($ email); / * For each email ... * / foreach (email as $ email $ email_number) {/ * Get specific information for this email * / $ overview = imap_fetch_overview ($ inbox, $ email_number, 0); $ Message = imap_fetchbody ($ inbox, $ email_number, 2); / * Email header information * / output output / $ output. = '& Lt; Div class = "toggler". ($ Overview [0] - & gt; seen? 'Read': 'unread'). '& Gt;' $ output. = '& Lt; span class = "topic" & gt; ; '$ Overview [0] - & gt; subject.' & Lt; / span & gt; '$ output. =' & Lt; span class = "from" & gt; ' $ Overview [0] - & gt; From. '& Lt; / span & gt;' $ $ output. = '& Lt; span class = "date" & gt; on'. $ Overview [0] - & Gt; Date. '& Lt; / span & gt;'; $ Output. = '& Lt; / div & gt;' / * Email Body * / Output Output. = '& Lt; div class = "body" & Gt; '. $ Message.' & Lt; / div & gt; ';} $ output echo;} / * close connection * / imap_close ($ inbox);
It must be added to the attachment control and you can read it because this is the source code
Comments
Post a Comment