tags:

views:

23

answers:

2

Hi, maybe mine it's a bit a simple question; I would like to instruct my server to receive mails and to parse them via a php script. How can I do it?

Thanks

+1  A: 

Email is going to be sent to an email address that you chose. The email will be stored on either a POP3 or IMAP server and you will have to periodically poll the server to check for new messages. If new messages are detected, your app will then have to download and parse them, and then delete the message from the server.

There are a handful of classes / code snippets out there that will do most of the heavy lifting for you. (like this example). You'll probably want to configure the script to be executed via a cron job so it runs every 5 minutes or-so.

As a side note though, using PHP for this application is rather inelegant. PHP is designed to render HTML and interact with a user. Using a more general purpose language like Python or Perl would be a better solution.

jamieb
Or you can just have the MTA feed the email to a script, much as is described in the question that this one is a duplicate of.
Ignacio Vazquez-Abrams
the problem is that I'm not the administrator of the server and I have really little permissions on it (not to speak of knowledge). That's why I was hoping to lean on an external mail service.
Bakaburg
A: 

first,you should download the email from server.

Sam