email activating a web page impossible?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Is it possible to somehow activate a page containing a php script by sending
an email to a mailbox on the server?
I have a script that sends out notification emails to an individual. He
wants to receive them continuously until he decides he has seen enough of
them. Then to stop receiving the emails he has to use his browser and go to
the web page that is sending him the emails where he clicks a button.
Would it be possible to arrange things in some way so that all he has to do
is fire off a reply to the most recent email he has received to activate the
script that stops the emails being sent.
I don't see how this could be done, but thought I should ask here before
dismissing the idea.

Re: email activating a web page impossible?

Bill wrote:

Quoted text here. Click to load it

Sure, but it's not going to be the PHP part that's tricky. The reply-to
address will need to be an address that the mail server knows about,
then instead of delivering mail it gets piped to a script instead. For
instance, on my mail server if the reply-to address was,
in the domain alias file I'd put:

me: "|/path/to/script/to/run.php"

Then that script is run every time an email message is sent to it. Of
course, you'll want to check out phpinfo() to see what you have
available for variables from your MTA and such...

In case you are curious, my mail server setup is documented here: /

Justin Koivisto -

Re: email activating a web page impossible?

Quoted text here. Click to load it

Yes, but the requirements for doing it have much more to do with
what you're allowed to do on the server than with PHP.  If it's a
"sealed server" with your only access by POP3 or IMAP, it's going
to be harder (in which case, you need to have something grab mail
off the server and that something looks at the mail and sees if
it has to do something special with it).

Many (UNIX, especially) servers allow you to "pipe" incoming email
into a program, sometimes through the use of a .forward file in
your home directory.  Sometimes you pipe that mail into "procmail",
which can do all sorts of things to your mail depending on a
configuration file.  Also, maybe you have a nice sysadmin who will
put an alias that pipes into a program into the system alias file
for you (but he'll worry about security issues).

So, you write a script that receives the mail, decides if the mail
is the one you want (e.g. the subject line matches the one it's supposed
to trigger on), and then goes and accesses a web page to trigger off
your php script.  Be VERY, VERY careful about using pieces of the mail
to insert into a command; this can open huge security holes.

The script on the server could be written in anything, even command-line
PHP.  Or it could be written in shell, and use a command like:
    lynx > /dev/null
to access the web server to fire off your PHP script.

Quoted text here. Click to load it

Assuming you have a Reply-to: in the
messages, you can have an alias like:

    no-more-emails: "|/usr/local/bin/unsubscribe.php"

where unsubscribe.php is written in command-line php, it can look
at the email, figure out WHO is trying to unsubscribe, (looking at
the mail headers or some other kind of tag you stuck in the message)
and update the database to tell whatever is sending notifications
to stop.

Quoted text here. Click to load it

                    Gordon L. Burditt

Re: email activating a web page impossible?

Quoted text here. Click to load it

This isn't exactly what you asked for, but maybe it's an acceptable
alternative (to your client)...

If in the e-mails you send out, you put a link to a web page that's a
'auto-cancel' page (see below), then your client only has to click on that
link to cancel further e-mails.  Depending upon the OS and environment he's
running in, this is a single click.  It's easier than replying to the

The link he clicks on would be a URL of the general form:

where 'xxxxxx' is some unique ID you generate that identifies this guy and
identifies which kind of e-mail you want to cancel.  The guy doesn't have to
click on anything on the 'cancel.php' web page.  The mere fact that he
visits it (with that URL parameter) cancels further e-mails.

It seems to me that this approach is about on a par with replying to the
e-mail, and it might be a lot less complicated for you to implement (which
means cheaper, faster to get running, and more robust).

My e-mail address doesn't have a 2 in it.

Re: email activating a web page impossible?

Thank you all. These replies have each been very helpful to me! I am a
hobbyist programmer not a pro, so there are a lot of gaps in my
knowledge. Following on from your replies I have made enquiries of my
provider and learnthat I have ssh access to the server which has procmail
installed. I am now reading up about procmail.

Site Timeline