Re: PHP and connection to mail account

From: Date: Wed, 13 Dec 2006 15:48:03 +0000
Subject: Re: PHP and connection to mail account
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-245801@lists.php.net to get a copy of this message
Jochem Maas wrote:
Angelo Zanetti wrote:
Do u know if its possible with PHP to receive a mail or connect to a mail box and do something with an incomming email ? I see there is that imap_open() but also there are sockets.
    
indeed - basically use whatever you want! - I would suggest have a search online, there are quite a lot of mailbox related classes/libs/etc as well as fully featured php webmail packages that you might be able to scrounge some useful code out of. an alternative could be to configure your mail server to pipe the incoming email directly to your script (i.e. don't deliver it to a mailbox at all) - this has the advantage that your script doesn't have to run as a daemon (or via cron) in order to poll the given mailbox - it simply recieves the email on stdin whenever an email arrives.
Just to add something to consider... which way you do it can depend on what your script will be doing and how many emails you expect to receive. If the script is intensive and/or you are expecting a lot of emails you're better off cron'ing a script to deal with them otherwise your server could end up bogged down by those processes. I can't speak for other MTAs but I do know that with Postfix you can apply a limit to the number of simultaneous processes that are started if you implement it in the transport map. -Stut

« previous php.general (#245801) next »