I am looking for a package/bundle that can access an email inbox, retrieve the emails in the inbox and parse them (Sender Email, Subject, Body, Attachments) for processing in my Symfony2 application. The idea is a "helpdesk" where people can email a specific email address and a cron job will run through the email inbox and convert emails into helpdesk tickets (with attachments).
Before anyone tells me to Google or something equally unhelpful, please note that I have spent over an hour on Google as well as gone over more than 100 StackOverflow threads looking for something that can help me with this. Most of the content involves sending emails and not retrieving them. I have built a pure PHP parser before and it was a nightmare (as almost every email client composes the emails a little differently).
I found https://packagist.org/packages/lasso/mail-parser-bundle, but it seems to only be for Zend. I have also found https://github.com/iJanki/MailMimeDecodeBundle, but it seems to still be a work in progress and there is no documentation to speak of. Additionally, I found Correct way to retrieve mails by IMAP in symfony2, but that looks just like the start of the nightmare I had last time when I built one from scratch.
I would appreciate any suggestions or pointers from anyone who has implemented something similar or has been in a similar situation.
The POP3 (P ost O ffice P rotocol Version 3) is an application-layer Internet standard protocol used by local Email clients to retrieve Email from a remote server over a TCP/IP connection. This tutorial shows how to connect to POP3 mail server and manage incoming Email using the ‘telnet’ command.
To use EAGetMail POP3 & IMAP Component in your project, the first step is “Add reference of EAGetMail to your project”.
For example, you can choose menu -> Tools -> Accounts -> Your email account -> Properties -> Servers in Outlook express or Windows Mail to get your POP3 server, user. Using EAGetMail to receive email does not require you have email client installed on your machine or MAPI, however you can query your exist email accounts in your email client.
I have found a PHP class that does exactly what I wanted and neatly parses the emails into fromAddress, subject, body and attachments. It even saves the attachments to specified location on your server.
https://github.com/barbushin/php-imap
While it is not a Symfony2 Bundle, it is very easy to integrate into Symfony by supplying the class with a namespace and then using it in your desired controller.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With