multiple actions including mailto()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

multiple actions including mailto()

Post by Bill H »

User is viewing one record from a database, the id number of which is stored in a $_SESSION variable. When the viewer clicks on a link (button actually) I want the following to happen.

1. A flag in that record in the db is updated.
2. The email address and some other info is retrieved from the db.
3. The mailto() function is invoked using data from step 2
4. The $_SESSION variable is unset()
5. The screen is reset.

Step 3 needs to invoke the user's email client with address and subject filled in.
Step 5 ditches the record view and returns to the list view.
The order of events does not matter, except that step 5 needs to be last.

I know, of course, how to do each of the individual steps, and I've been doing a variant of them using the mail() function. The problem is that that doesn't leave the user with a record of the sent mail (which could be overcome with a cc), but in this case mail() is not working anyway.

The host (and this is not uncommon on shared hosts) stores mail() messages and sends them based on server load, so they may be delayed significantly. So using the regular email client is to their advantage for a number of reasons. I don't have a problem using mailto() by itself in a <href>, but I'm not having much luck making it automatically one of a series of actions.

The present process is within a javascript popup which accepts message input, but I am in the process of reworking this site to eliminate all javascript (another reason for the change from mail() to mailto()) so I would really like to aviod using it here if at all possible.

Anyone?
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

mailto is not a function, it is a protocol that invokes the users Email client. The email is sent from the client and not the server.

If you want to mail from the server - use mail()
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

..I've been doing a variant of them using the mail() function.
I don't have a problem using mailto() by itself in a <href>...
Step 3 needs to invoke the user's email client with address and subject filled in.
I did misspeak, step 3 should have read "3. The mailto() process is invoked..."

That being clarified, anyone?
Post Reply