Server-side E-mail scripting

238 views Asked by At

I have a project idea in my head that I am considering trying to execute, but this desktop programmer doesn't really know where to begin when it comes to web server development!

I would like to have a script respond when an e-mail is received at an address, which would query a database, make some decision, and then possibly forward this e-mail to another address. I know I can accomplish the actual parsing and database interaction in Perl or PHP (or really any scripting language) if I write the script and put it into my hosted CGI-BIN directory. But beyond there, I'm a little lost.

In summary:

My specific question is: How do I in essence 'hook in' to the mailbox and execute a script when an e-mail is received?

My more general question is: How do I respond to user events beyond just a requesting a URL? If I wanted to run an application for accepting License codes, for example, how would I accomplish that? (listening for messages on an open socket or port, executing actions against a database, etc.)

My (possibly too-broad) question is: What would my next step be in going deeper? What books or resource made it all click, and made you fell like you had the strength of 1000 IT (wo)men?

More about my background/what I already know:

I've never ventured too far in web development, but the world has grown so interconnected, I can't really continue to sit in the dark. I know how to code and script, write PHP/MySQL websites, and I can navigate a *nix machine with some competency.

Have spent the last 5-10 years focused in the C-family of languages. I replaced a crude knowledge of ASP with a crude knownledge of PHP, with very little JavaScript; lots of VBScript and more recently, Python.

1

There are 1 answers

3
Novikov On

You'll need to poll the POP3/IMAP mail server for messages. PHP has libraries for handling those protocols for you PHP IMAP. The next step is to get that script running. The most rudimentary way of doing that is to execute it as a cron task that checks the mail server and responds to the emails. On the other hand PHP is not necessarily the language for automating background tasks. Perl has those facilities also, as does Python.