How to automatically reply to an email

I’m trying to create a system that will automatically reply to an email that is sent to a particular address. But this is not just a simple autoreply like the ones one would send while on vacation–it would include a link to a particular address, and the email address would be included in the get values in the URL.

Basically, here’s what would happen:

  1. A user would get the email address that I am using for this, usually from a QR code.
  2. The user would send an empty message to the address they received.
  3. As soon as the message is received, my server would send a reply that includes a link to a signup page
  4. When the user clicks on the link, the get values in the link would automatically add the user’s email address to the signup data so that the user would not have to enter it in manually. The user then adds the other relevant information and submits the form.

This is actually a very common procedure here in Japan. For example, restaurants will often have a QR code on their menu or a poster with an email address that does what I just described. When a user signs up, they often receive some kind of a gift like a coupon for a free drink or 10% off their bill. From there, the user then gets messages with promotional offers, including coupons.

They often do this because many people here like to sign up to these services with their cell phones, but they often either can’t or don’t want to manually enter in their email addresses, mainly because they are usually made to be long and convoluted in order to prevent spam.

I guess what I’m asking is, is there any way for a server to detect that a message has been received, and then run a script to do what I’m looking for, or would this have to be done via a cron job that has a short interval, like 30-seconds to 1 minute. And if it is the latter, will that cause any strain on my system?

Anyway, I hope someone can answer this question. I’ve tried Googling similar things, but I’ve come up empty. Any help would be greatly appreciated.