Click to See Complete Forum and Search --> : Send Multiple Form Fields with Sendmail


gschimek
11-16-2004, 11:11 AM
I've got a website with an evaluation form on it with multiple fields to fill out. I've written a perl script that takes the data from each field and then writes it to a different file for each field, so that each data file only contains information from one certain field.

That part all works fine. But what I'd like to do is be able to email all that data to me each time someone fills out the evaluation form. I've been able to write a script that takes an email address, subject, and body of a message and send it using sendmail, but I don't know how to do it with multiple fields. And since I want the script to do more than just email (i.e. creating the separate files from above) I can't just used a canned form2mail script, or at least I can't use one of them by itself.

So how can I take information entered into multiple fields and email them with sendmail? Do I need to put the field data into a hash somehow? Or is there a better idea.

ph34r
11-16-2004, 12:06 PM
Take a look at how a generic form2mail script works - I've attached one I wrote in PHP. Notice how it just loops thru everything in the POST array and either puts it in the body of the message or does something special with it (ignore, use for specific fields, etc).

bwkaz
11-16-2004, 08:49 PM
You could cat all the files together and then pipe them to sendmail. sendmail should then treat all that input as the body of the email message. In your script:

cat file1 file2 file3 file4 | sendmail -XYZ You would have to replace XYZ with whatever options sendmail normally takes.