Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to extract mail attachment with PHP?

I'm extracting emails from a database where they're stored as strings. I need to parse these emails to extract their attachments. I guess there must already be some library to do this easily but I can't find any.

user-image
Question added by Zaid Rabab'a , Technical Team Lead , ESKADENIA Software
Date Posted: 2013/02/12
Faizan Ahmad
by Faizan Ahmad , Software Engineer , cardekho.com

Download the email class http://www.electrictoolbox.com/php-email-message-class-extracting-attachments/

Panneer selvam xavier
by Panneer selvam xavier , Supply Chain Analyst / Trainer , Infonet

i hope this will help you http://stuporglue.org/recieve-e-mail-and-save-attachments-with-a-php-script/

Feras Abualrub
by Feras Abualrub , Web Solutions Manager , Qistas for Information Technology

I've done it once with CodeIgniter MVC , they have useful library for emails (thats why i prefer MVC Frameworks ), you can check this like to get idea about it :http://garrettstjohn.com/entry/extracting-attachments-from-emails-with-php/   However, check this page i believe its very useful also for pure PHP code structure: http://www.electrictoolbox.com/extract-attachments-email-php-imap/

Rani Alomari
by Rani Alomari , Full Stack .Net Developer , Jordan Center for Diseases Control (JCDC)

i usualy use MIME library

islam khalil
by islam khalil , Technical Manager , iCloudit

Use this Library: https://github.com/barbushin/php-imap/blob/master/example/index.php Example Code: require_once('../ImapMailbox.php'); // IMAP must be enabled in Google Mail Settings define('GMAIL_EMAIL', 'some@gmail.com'); define('GMAIL_PASSWORD', '*********'); define('ATTACHMENTS_DIR', dirname(__FILE__) .
'/attachments'); $mailbox = new ImapMailbox('{imap.gmail.com:993/imap/ssl}INBOX', GMAIL_EMAIL, GMAIL_PASSWORD, ATTACHMENTS_DIR, 'utf-8'); $mails = array(); // Get some mail $mailsIds = $mailbox->searchMailBox('ALL'); if(!$mailsIds) { die('Mailbox is empty'); } $mailId = reset($mailsIds); $mail = $mailbox->getMail($mailId); var_dump($mail->getAttachments());

More Questions Like This