0

Possible Duplicate:
How do I receive email and process it in a web application

I simply was just thinking and I thought, wouldn't it be cool if my users could email us their posts and the server will post it for them.

So, John Smith might email "Wassup everyone" to post@mysite.com and it would post it for him?

Is there some kind of service that will do this, certain php function?

I'm just simply enquiring...

Community
  • 1
  • 1
Frank
  • 1,844
  • 8
  • 29
  • 44

2 Answers2

3

"One way to process the incoming messages is to configure the local mail server to start a PHP script when a message arrives on a given mailbox.

To achieve this, you need to learn specific details of how to configure your mail server because each mail server works in a different way.

For instance, if you use qmail mail server, you need to setup a .qmail file associated to the e-mail address that you want to handle. The .qmail file must contain the command that will be executed to start the PHP script that will handle the incoming messages.

...

An alternative solution to process received e-mail messages using PHP is to associate the incoming addresses to mailboxes accessible using POP3 or IMAP client scripts.

In this case, the messages are received and stored by the mail server, so they can be processed later by applications.

PHP scripts can use existing POP3 or IMAP client classes or extensions to regularly poll the mail server and retrieve the messages to perform the necessary processing tasks.

To perform this periodic poll, you can use the PHP CLI version command to start a PHP script by adding a task to cron on Linux and other Unix like systems, or the task scheduler on Windows.

Depending on how important the incoming messages may be, you may adjust the frequency of execution of the mailbox polling script."

http://www.phpclasses.org/blog/package/2/post/1-Process-incoming-email-messages-using-PHP.html

Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133
1

Not a php function, but there are libs that allow you easily reading email from server-side. The latest I saw was in Apache zetaComponents http://incubator.apache.org/zetacomponents/ . But I would prefer something more real than PHP for acting as a daemon, reading mail in every N timeframe and putting contents to DB.

Mr. BeatMasta
  • 1,265
  • 10
  • 10
  • Also, I think bash-scripting is best here :) of course if you use linux on server. It would be much more easy for bash to access mail contents file in the user's home directory while infinitely looping – Mr. BeatMasta Dec 31 '11 at 02:01