how to download mails attachment using IMAP and php -


I am using this code for download attachments from Gmail

  $ savedir = __DIR__ '/ IMAP-dump /'; $ Inbox = new IMAP mailbox ($ hostname, $ user name, $ password); $ Email = $ inbox- & gt; Search ('ALL'); If ($ email) {Resort ($ email); Forex Currency ($ Email $ Email) {foreach ($ email-> getAttachments () as attachment) {$ savepath = $ savedir $ Attachment-> GetFilename (); File_put_contents ($ Saving Path, $ Attachment); }}}  

But when we execute it, this error indicates can not connect to Gmail:

  gmail-imap.l.google Can not connect to Com, 993: Connection refused  

How can I solve this problem?

Verify the connection in your IMAPMailbox class. The code you posted is the procedural code and does not handle the connection. Please edit your op and add the IMAP mailbox class.


Comments