开发者

How to run code when you receive an email

开发者 https://www.devze.com 2023-04-10 10:38 出处:网络
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

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

I would like to something similar with PHP, except do something like this:

Have the user text:

msg@gotsi.co.cc

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.

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.


Well there are two choices:

  • 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 from stdin.


I had this question too and I wanted to get emails in real time so I worked out my own solution with google app engine. I basically made a small dedicated google app engine app to receive and POST emails to my main site. That way I could avoid having to set up an email server.

You can check out Emailization (a little weekend project I did to do it for you), or you this small GAE app that should do the trick.

I kinda explained it more on another question.

Hope that helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消