服务器端电子邮件脚本
我脑子里有一个项目想法,我正在考虑尝试执行,但是这个桌面程序员在 Web 服务器开发方面并不真正知道从哪里开始!
我希望有一个脚本在某个地址收到电子邮件时做出响应,该脚本将查询数据库,做出一些决定,然后可能将此电子邮件转发到另一个地址。我知道如果我编写脚本并将其放入我托管的 CGI-BIN 目录中,我可以用 Perl 或 PHP(或实际上任何脚本语言)完成实际的解析和数据库交互。但除此之外,我有点迷失了。
总结:
我的具体问题是:我如何本质上“挂钩”到邮箱并在收到电子邮件时执行脚本?
我更普遍的问题是:除了请求 URL 之外,我如何响应用户事件?例如,如果我想运行一个接受许可证代码的应用程序,我将如何实现? (监听开放套接字或端口上的消息,对数据库执行操作等)
我的(可能太宽泛)问题是:我的下一步要深入什么?哪些书籍或资源让这一切变得精彩,让您觉得自己拥有 1000 名 IT(女性)人员的力量?
更多关于我的背景/我已经知道的事情:
我从来没有在网络开发方面冒险太远,但世界已经变得如此相互联系,我不能继续坐在黑暗中。我知道如何编码和编写脚本、编写 PHP/MySQL 网站,并且我可以以一定的能力导航 *nix 机器。
过去 5-10 年一直专注于 C 系列语言。我用 PHP 的粗略知识取代了 ASP 的粗略知识,很少使用 JavaScript;很多 VBScript 以及最近的 Python。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要轮询 POP3/IMAP 邮件服务器以获取邮件。 PHP 有一些库可以为您处理这些协议 PHP IMAP。下一步是运行该脚本。最基本的方法是将其作为 cron 任务来执行,该任务检查邮件服务器并响应电子邮件。另一方面,PHP 不一定是自动执行后台任务的语言。 Perl 也有这些功能,Python 也有。
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.