문제

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 service@stockreporter.com 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?

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top