Integrating email into PHP app

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello hello.

I have a dilemma on my hands. I have an application, in production,
which uses PHP's IMAP libraries to read inbound emails in a mailbox.

Email is tightly integrated into the app itself.

The problem is it's a nightmare. The permutations of character encoding,
dispositions, attachments make it a very tricky thing to handle. I'm
just not happy with it going forward.

So what to do? Integrate an existing IMAP client into the current
framework? But nothing seems that simple. Pick apart an existing GPL
IMAP client for its libraries and use those? Or just keep going until I
get it right.

Has anyone been in a similar situation and do they have any pointers?

Re: Integrating email into PHP app

Quoted text here. Click to load it

I haven't tried this myself, but I suspect that using a separate
library is going to be a pain unless it already has PHP bindings or
you're comfortable writing them yourself.

Is there a way that you could use something outside of PHP, e.g. a
C/C++/Python/Perl/Ruby program to preprocess the messages to ease the
problems you're having?
Charles Calvert             |  Web-site Design/Development
Celtic Wolf, Inc.           |  Software Design/Development |  Data Conversion
(703) 580-0210              |  Project Management

Re: Integrating email into PHP app


on 06/10/2009 05:03 AM Hugh Oxford said the following:
Quoted text here. Click to load it

I use this MIME message parser class. You just pass it a complete
message with headers and body and the Analyze function just returns a
simple to process structure of the message spliting text, HTML,
embedded, attached message parts.

You may also want to read this article about processing incoming e-mail


Manuel Lemos

Find and post PHP jobs /

PHP Classes - Free ready to use OOP components written in PHP /

Re: Integrating email into PHP app

mlemos wrote:

Quoted text here. Click to load it
Quoted text here. Click to load it
Thanks Manuel

I'm aware of your classes and will give them another look.

Re: Integrating email into PHP app

Quoted text here. Click to load it

Email messages complying with the Internet RFCs can only be of two
types - either inline 7-bit ascii text in the body or mime-encoded. If
they are mime-encoded, then they can only contain base64 or quoted/
printable (again, both are 7-bit ascii).

Of course, if it is base64 encoded, then there can be other encodings
embedded within the attachment (e.g. a compressed(mime encoded(tnef
encoded(ole encoded(file))))? - but its still just an attachment.

So emails are ALWAYS 7-bit ascii.

All you need to do is split out the attachments and provide them as
downloadables then display what's left on screen. That way you leave
it to the user's browser to determine how to handle the contents.

If you really want, you could later add handling for specific content


Site Timeline