tags:

views:

36

answers:

3

I'm investigating the development of a new forum and found via user feedback that posting to the forum via their email client would be a very useful feature.

I'm wondering: is it possible? Can php check for an inbox folder and turn each email into a forum post? And if so, how to do that in a LAMP environment?

+1  A: 

You can create a sceduled (crontab, windows scheduler) script which does the job (reads all the incoming files from SMTP drop folder and posts the messages). However, two questions arise:

  • how will you know which thread to post to?
  • how will you filter spam messages?
naivists
+1  A: 

PHP has IMAP functions that can read POP3 mailboxes. You would want to combine those with a cron job for frequent polling.

Some mail servers also offer triggers to run when mail comes in - you could create a trigger that calls a PHP script, passing on all the details of the incoming message. If you have access to your server and can implement this, it might be easier to work with because you don't have to connect to the POP mailbox yourself in your script.

If you have a POP3 mail box with good spam checking, this might work - although you would, as Naivists says, of course have to find a method how to identify the target thread reliably.

Pekka
+1  A: 

Setting up a script triggered by receipt of email to a particular address would be the simplest. That way you don't need to write a new cron script. You would want to create a special email address dedicated to receiving such emails. The thread could be identified by something in the subject that would be required. I'm not sure of your use case so that's the best I can suggest. And you could also require the email to contain something to identify the sender as one of your authenticated forum members. You might need to expose a secret token to them or something. That way if any spammy stuff gets in you can block the account of whoever is sending it.

I believe some opensource forum software has this built in, or has an add on you can install to do it. Even though you're doing your own, you might like to get these modules to see how they do it.