views:

34

answers:

2

Hi,

i'm buidling a very simple email based website that users can, when registering list out all the stocktickers they're intersted in following. The program then on a daily basis goes and fetches that information and sends it out to every user. i have the portion which fetchs the information from the stock websites, but i'm looking for an "infrastructure" that allows:

(a) a user to send an email to [email protected] with the subject "Subscribe" and with the body containing stockticker values,
(b) user to send email to service@... with subject "unsubscribe" and body containing similar values.

Looking for code in php please. Any insights?

A: 

Create a php script that constantly checks that email address. When it receives an email it can use the senders email for identification and then just parse the email to run the specified command for that user

http://php.net/manual/en/book.imap.php

Galen
+1  A: 

Create a php script and "pipe" emails sent to the specified email addresses into it.

An example tutorial is available here - http://www.evolt.org/incoming_mail_and_php

This way, the script is triggered, on demand, when a subscriber contacts it to either add subscriptions or remove them. The script can then parse the contents of the email, along with the header (which would contain the sender's email address, subject, etc.) and make the required changes within your system.

A suggestion such as that from Galen would also work, however, having a script which polls an email account at regular intervals (using cron, or similar), in my experience is not as reliable or as instantaneous as piping email to a script.

Lucanos
Marvelous... that sounds like exactly it - will check it out!
Dave