2

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: [email protected]
From: [email protected]
Subject: hello!
Message: Hey man whats up?

Would make a http request to

http://example.com/notify.php

With some POST data:

[email protected]&[email protected]&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.

2 Answers 2

2

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.

2
  • Is this possible in a shared hosting environment with SSH access enabled? The host will generally change config on the server to enable features so even if something has to be changed at a global level is this easy to implement on a per-user/domain basis? For example only redirect emails for *@example.com and not *@example.info Commented Feb 16, 2010 at 1:54
  • As long as you can set up aliases and not just virtusers, you can make this work. Just create your alias with some hard-to-guess name or something like that, then set up your virtusers to forward mail to the alias as desired. Commented Feb 16, 2010 at 2:05
0

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.

2
  • The problem I see with this is that it's going to have to check the e-mails of every account (every member of my site gets one) which will probably won't scale well. It has to do it all the time not just while the user is logged in because it does certain actions based on the content of the e-mail Commented Feb 16, 2010 at 1:48
  • I see. Didn't realize you'd have multiple boxes to check. In that case, I would go with Ignacio's mail transfer agent answer.
    – Jacob
    Commented Feb 16, 2010 at 1:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.