Mail to a PHP script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bigmac2889
Forum Newbie
Posts: 1
Joined: Wed Dec 10, 2008 9:58 am

Mail to a PHP script

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Mail to a PHP script

Post by requinix »

Not really. PHP is for the web, not email.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Mail to a PHP script

Post 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.
Post Reply