What I would like is a service (preferably something not installed on a server like just letting a third-party handle e-mails but if a dedicated server is necessary I'll give it a shot) that allows any e-mails to my site to be redirected as a HTTP request to a php script I specify
For example a e-mail like this
To: chris@example.com
From: anotherplace@another.site.example.org
Subject: hello!
Message: Hey man whats up?
开发者_StackOverflow
Would make a http request to
http://example.com/notify.php
With some POST data:
to=chris@example.com&from=anotherplace@another.site.example.org&subject=hello!&message=Hey man whats up?
I'd like to avoid polling every minute as I believe this would be a major drain on the server. Is there any pre-existing mail server or service that has these sort of features? My other plan would be to implement my own mail server but that seems like a huge project to undertake just to support this.
Set up a pipe alias in your MTA:
autoprog: |myscript.php
At that point you can have your script parse the email and open a URL with it properly encoded into the query string. Or it could just process the email directly.
Polling a mail server every minute to check an inbox shouldn't be a major drain on the system. Most email clients do exactly that. If the email server is IMAP, POP3, or NNTP, and you want to use PHP to query for received mail, you could do the polling using the IMAP extension for PHP.
精彩评论