Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP form processing: How to send multiple emails? 2

Status
Not open for further replies.

Muppsy007

Programmer
Apr 4, 2003
98
NZ
Hi there. I'm a bit of a php novice I think this is more of a design question than a technical one.

I'm doing work for a company that offers free medical advice to scuba divers by way of a contact form. Because of demand, it can take up to 3 hours for the doctor to answer, so we are wanting to give instant feed back to the customer via an email sent directly to the address entiered.

At the same time, we want the details of the form emailed through to the doctor.

At present, I am using a formmail script to send the message to the user written by tectite.com. This script allows me to send a confirmation message, with particulars from the form, to the user in nice html form - perfect.

But how is the second email usually sent? What I mean is, with online ordering companies, you usually get an automated response within seconds. How do they process two formmails at once? I have tried using two different formmail scripts, but i seem to have trouble with the variable names being declared as hidden fields on the form.

I hope this makes sense, thanks for any tips.

 
You need to go into the code and find the place where the mail is sent out. It will probably use the mail() function.
After that it is just inserting another mail command with the appropriate PHP code to send mail to whoever you want.
 
Thats DRJ,

I think I should explain a little further..

I am using a great script from that sends mail to a set recipient (eg, the webmaster) using a totally seperate HTML file.

With this template system, you can simply create a table on a page, and just write the PHP variables from the form in the cells (as plain text, not php!), add some formatting and voila, it's sent through to us when the form processes.

The trouble is, the developer of this script has coded the script so you can't send the e-mail to anyone but those specifed in the script. Which means that there is no way to use the script to send an instant, HTML template response. Which is exactly what I'm trying to do.

I have run through the script for several weeks now, trying different things, even making a copy of the script for customer autoresponse, and one for our response. Nothing seems to work and being a novice doesn't help.

I guess what I'm really after is how this person was able to construct the headers of the email to have the entire content not only send this seperate HTML file, but populate the variables in it. I'm really determined to do this because of the scalability it offers.

I know how to construct an HTML email using PHP, but it is tedious and must be done for each individual situation.

If anyone has seen this type of external template thing done in an online tutorial or book, please point me in that direction.

On a side note, does anyone know how the big companies handle this sort of thing? Like when you order from Dell or an airline, you get a nice formatted email with all your order details in it. Do their programmers hand program a script to handle each situation or something, or are there expensive products out there to do this?
 
if, in your form you capture th email of the user, simly copy the mail portion of the code and insert the new email addy in the "to" section...

If you could post the relevant section of code, we could help more

Bastien

Cat, the other other white meat
 
Hi Bastien/DRJ

I'd like to kick off by saying thanks for your help, I've finally worked it out.

The main problem was the fact that I am by all accounts, a bloody idiot.

Although I'm not overly familiar with PHP, I didn't seem to think about common variable scope in the script. You see, I was trying to use the $email variable gleaned from the user, in functions that it was not even passed to. Hence nothing happening. I'm sure that if I had told you that mail() was called from within a function, you would have seen it straight away.

So I found the send, and followed it back until I found the first call from the main script.

Honky Dory

Thanks again. I'm sure I'll be back if I keep this up. For now, I'm off to give myself an uppercut.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top