收到电子邮件时如何运行代码 [英] How to run code when you receive an email
问题描述
我正在为社交网络制作移动产品,我们要添加的功能之一是文本到状态。不过,我们正在做一些不同的事情,类似于YouTube的移动上传。 YouTube使用以下电子邮件:
I'm making a mobile product for a social network and one of the features we would like to add is text-to-status. We are doing something different though, similar to YouTube's mobile upload. YouTube uses emails such as:
12598601913@m.youtube.com
我想使用PHP进行类似的操作,除了要做类似的事情:
I would like to something similar with PHP, except do something like this:
具有用户文本:
msg@gotsi.co.cc
然后,服务器收到该消息后,它将检测帐户中保存的电话号码(例如: 5551202109@vtext.com
) ,有点像Facebook / Twitter如何使用其短代码。
Then when the server receives this it will detect the phone number(for instance: 5551202109@vtext.com
) saved on the account, sort of like how Facebook/Twitter work with their shortcodes.
我已经对此进行了大约3-4个月的研究,但实际上什么都没想到。如果有人可以帮助,那就太好了。只是一个说明,我对PHP和服务器端Javascript以外的任何服务器端编码都不太熟练。
I have been researching this for about 3-4 months and nothing has really come up with much of anything. If anyone can help it would be wonderful. Just a side-note, I am not very fluent in any server-side coding other than php and server-side Javascript.
推荐答案
有两种选择:
- 您可以配置邮件服务器以将邮件放入邮箱,然后运行一个PHP脚本, cron或此类工具不时轮询它并获取新邮件
- 或者您可以将邮件服务器配置为在收到邮件后执行程序。通常,通过为
| / usr / bin / php /path/to/script.php
之类的别名指定别名,然后从<$ c $接收邮件c> stdin 。
- You can configure your mail server to put the mails in a mailbox and then have a PHP script run by cron or such polling it from time to time and fetching new mail
- Or you can configure your mail server to execute a program once a mail is being received. Often this is done by specifying an alias to something like
|/usr/bin/php /path/to/script.php
which will then receive the mail fromstdin
.
这篇关于收到电子邮件时如何运行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!