Forum Moderators: coopster

Message Too Old, No Replies

2 emails from one form?

using PHP to send info to company *and* user

         

doodlebee

12:07 am on Aug 30, 2005 (gmt 0)

10+ Year Member


I have a pretty nice PHP form script that I've developed over time (don't know how great it is - just know it works) - I'm no guru and I sort of stumbled into what I've done, I'm utterly amazed it's been working.

Anyway, I have a client who is in need of a certain customization to it. I've googled and tried to find the answer, but I don't know how to put in the query string properly to get relevant answers. So, I'm hoping someone here can help me.

Right now, I have the form set up so when the user fills out the form and clicks "submit", he is redirected to a "Thank you" page, and the information he has submitted is sent to the client.

What I need *now* is for the above to happen, but the reason for the form is so that the user can request a file. The client wants to be notified when someone requests the file (and as stated above, he will be), but he wants the file e-mailed to the user automatically.

So, I need to find a way so that when the user submits the form, not only does the usual happen (stated above - info from the form sent to the client), but a standrad e-mail is sent *back* to the user with the client's file attached, all automatically.

I'm sure there's a way to do this, but I just can't figure it out - I'd appreciate any help I could get. My PHP code is below, if that would help (I've left out the required fields stuff and cookies to make it easier to read):

<?

if($action!="sendmail"[smilestopper]){
include ("paper.html"[smilestopper]);

exit;

}

if ($action == "sendmail"[smilestopper]) {

$message = nl2br("Name: $title $firstname $lastname

Company: $company

Phone: $phone

e-Mail address: $email"[smilestopper]);

$message = stripSlashes($message);

$mailheader = "From: $name <$email>\nContent-Type: text/html";

mail("Client Company Name <email@thecompany.com>","$subject","$message","$mailheader"[smilestopper]);

}


{
include("thanks.html"[smilestopper]);

exit;

}

?>

I'd appreciate anyone's help on this...thanks!

jatar_k

12:47 am on Aug 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



is emailing the file the only option?

what about serving them up a link to it after?

coopster

5:16 pm on Aug 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Good point, jatar_k. It will be much easier and if you can go that route, do so. If you do indeed find that you need to mail attachments, you just have to develop the appropriate headers and send it off. If you aren't prepared to roll your own code on this one, I think you'll find the PEAR Mail_mime [pear.php.net] package quite handy.

doodlebee

10:04 pm on Sep 7, 2005 (gmt 0)

10+ Year Member


Sorry it took so long to respond - I thought I had this set so any replies would be e-mailed to me!

Yes, serving up a link as an option has come up. The client is considering that possibility and (fingers crossed) he goes for that - I *can* do that - that hasn't been an issue. but if he decides to have the e-mail attchment sent, then I still need to figure out how to do so.

I *did* figure out how to send 2 different e-mails from one form to 2 different recipients - that was pretty easy. I just still need to igure out how to send one of those with an attached file. (And I'm willing to mess with headers to do so - I just need a pointed in the right direction on how to do it).

If you all have any more suggestions, I'd appreciate it - in the meantime, I'll go check out that form...