views:

38

answers:

2

Tumblr (the short form blogging platform) has a feature where you are given a unique email address (for example, [email protected]) that you can email text or images and it automatically formats it into a post for you (as long as the sending email address matches your account email address).

I'd let to set up something similar, but solely as a method to submit images. Ideally, when a user signs up to my site, I'd create a unique address for them and store it in my db (MySQL). If a user emails a photo to that address using the email address they signed up with, i'd route it to a PHP function that breaks it down and handles the upload of content to their account.

How would I go about setting something like this up? Would it be something at the DNS level, or Apache level? Would I need to create a "safe list" of all the "real" email accounts on my domain to pass it through first? Also, I'm using Google Apps for email on this domain, will I need to create some sort of filter on that end?

Any ideas/suggestions would be awesome!

A: 

It would be at the MTA level. Most MTAs have a facility whereby an email can be piped to an external program; this program would then parse the email and store the image.

Ignacio Vazquez-Abrams
How would I interface with the MTA? Is it something at DNS level, or more accessible?
Mike Diena
It's at the MTA config level. In sendmail you can add an alias that starts with a `|` to create a pipe alias; I believe other MTAs work similarly.
Ignacio Vazquez-Abrams
+2  A: 

There's another quick and dirty way to make this work...

Setup a "catch-all" address for your domain. In other words, setup your domain so that e-mail sent to any address at the domain automatically gets forward to one catch-all address (i.e. [email protected]).

Then, on the PHP side... Setup a script that periodically checks the e-mail in the [email protected] box. Be sure to check the "To:" field so that you can identify which specific user the message was intended for.

Hope this helps!

tambler