Importing Outlook Express / Thunderbird emails to PHP

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Importing Outlook Express / Thunderbird emails to PHP

Post by impulse() »

Has anybody achieved this before or knows of a way to do so? I understand there may be some manual work on the users side but I'm not sure how possible/easy it would be. I thought maybe use fsockopen to connect to a mailserver and retrieve e-mails, but I can see trouble arising.

Regards,
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

check out the imap functions in php - there are lots of useful nuggets there. Don't be put off by the name, it works with most POP accounts as well.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I still recommend using a system_filter with Exim4 and piping incoming mail directly through a PHP script at SMTP time. It's just a shame hosts don't offer users their own system_filter files. Exim4 does support this, and CPanel runs with Exim4, but it's not configured that way.

I do this quite a lot. We have an incoming mail server at work which I've set up to store mail in a database linked with users in our system. I also used to use this technique to log border-line spam in a DB. I'm also about to write one to keep track of PayPal payments as the emails get sent to me. It's not difficult if you have access to the Exim configuration, or if your host provide user-level Exim configuration.
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I'm not going to be doing this as originally planned. Now I will be using an e-mail parsing class to parse an uploaded .EML file. Most of this is going well at the moment, I'm able to extract the from, to & subject information from the .EML file but I'm clueless on how to extract the attachment data from the .EML file. Can somebody throw a suggestion at me please.

Regards,
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Depends a little bit on the class you're using.
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I'm using a parser class from phpclasses.org named MIME e-mail parser. I have read through the brief documentation that came with the class but it doesn't explain how to parse the attachment. The parser can see the attachment filename but I'm not sure how I would handle the attachment to save it to a location.

Regards,
mlemos
Site Admin
Posts: 126
Joined: Mon Apr 29, 2002 4:14 pm
Contact:

Post by mlemos »

impulse() wrote:I'm using a parser class from phpclasses.org named MIME e-mail parser. I have read through the brief documentation that came with the class but it doesn't explain how to parse the attachment. The parser can see the attachment filename but I'm not sure how I would handle the attachment to save it to a location.
It seems you have run the example script without changing it. In that case you need to change the parameters array, comment the SkipBody parameter and uncomment the SaveBody parameter setting it to the directory where you want to the message body part files to be saved.

If you leave the SaveBody parameter commented out, the message body parts are returned in the message decoded array as strings. This is not good for large messages as it may exceed the PHP memory limit.

Anyway, for more questions about the MIME parser class, please use the its package specific forum in the PHP Classes site.
Post Reply