Page 1 of 1

Mail to a PHP script

Posted: Wed Dec 10, 2008 10:02 am
by bigmac2889
Hello, I am curious if it would be possible to have a email forwarded to a php script, and then have that script take information from the e-mail and say put it into a database. Anyone know if and how one could do this.

Re: Mail to a PHP script

Posted: Wed Dec 10, 2008 2:32 pm
by requinix
Not really. PHP is for the web, not email.

Re: Mail to a PHP script

Posted: Wed Dec 10, 2008 9:04 pm
by Chris Corbyn
tasairis wrote:Not really. PHP is for the web, not email.
Actually, it is possible. You need to have access the the mail server though. Most mail server daemons provide a way to pipe the mail into a process. That process can easily be a PHP process.

I've done this before with Exim4. I'll warn you though, it's not trivial.

EDIT | Also, I had grand plans of writing a daemon for Swift Mailer to accept mail directly into a PHP application, but it hasn't eventuated yet. You'd need a VPS to run it so you could bind to port 25.