2

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.

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
Jake
  • 1,469
  • 4
  • 19
  • 40

2 Answers2

4

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.
J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
johannes
  • 15,807
  • 3
  • 44
  • 57
  • I actually like this and makes it seem less complicated than I though, but i'm not accepting it just yet to see if anyone else has a method that may work even better. Thank you very much though. – Jake Sep 30 '11 at 23:24
  • Well the third option I can image is writing your own mail daemon which will receive the SMTP communication, but existing MTAs are good for that ;-) – johannes Sep 30 '11 at 23:27
  • You also have the option of sending the message to the app via http rather than running the script directly which can create an overhead and isn't load balanced etc. I wrote a blog post at http://steve.dynedge.co.uk/2010/09/07/incoming-email-in-rails-3-choosing-the-right-approach/ explaining some of the options. It's rails but the ideas apply to php too. – Steve Smith Oct 01 '11 at 08:59
1

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!

Community
  • 1
  • 1
Capitao
  • 285
  • 3
  • 3