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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with form field in subject line

Status
Not open for further replies.

guigrrl

Vendor
Joined
Jan 14, 2004
Messages
5
Location
US
i'm using matt's formmail script to process a form from my website...but i don't know how to make one of the fields appear in the subject of the email. can anyone help?

thank you.

lisa AKA guigrrl
 
Hi Lisa
This works on our particular server - The name will probably be different but the syntax of most form mailing scripts appears similar.
Hope this is of use.

open( EZMAIL, "|/bin/easymail -t" ) or return 1;
print EZMAIL "From: contact\@YOURDOMAIN\n";
print EZMAIL "To: sitecontact\@THEIRDOMAIN\n";
print EZMAIL "Subject: SUBJECT LINE\n";
print EZMAIL "SOME EMAIL CONTENT\n";
print EZMAIL "SOME MORE EMAIL CONTACT\n";
close( EZMAIL );
Keith
 
Hi guigrrl

what is the URL of the website?

Duncan
 
whoops...

are you still needing an answer to this post?

sorry!
Duncan
 
well, yes and no.
i'd love to know how to do it, but
i've hired a perl guy to do it.

thanks
Duncan!
 
I see!

sorry I did not get back to u previously...

basically this is the situation - I will mention everything so I apologise if it mentions stuff you already know:-

The form ACTION is either GET or POST... GET will append data to the end of the URL like (after the qestion mark). POST carries this information invisibly.

GET becomes stored as $ENV{'QUERY_STRING'} or if you use POST then this is retrieved as:-
read(STDIN, $data, $ENV{'CONTENT_LENGTH'});

this data, in either situation, can be chopped up. All the data is stored as one long string of name/value pairs. This looks like surnname=Carr&forename=Duncan
This name/value pairs can first be split on the '&' then split finally into the name and value parts.

then you can make use of the data by storing all this information in variables, for example:-

[blue]@nameValuePairs = split(/&/, $data);

foreach $chunkOfData (@nameValuePairs)
{
($name, $value) = split(/=/, $chunkOfData);
$data{$name} = $value;
}[/blue]

then you will end up with something like this:-

[red]open (MAIL, '| /usr/sbin/sendmail -t');
[green]print MAIL "To: $data{email}\n";[/green]
print MAIL "Cc: \n";
print MAIL "Bcc: someone\@whateverisp.com\n";
print MAIL "From: webmaster\@my-mot.co.uk\n";
print MAIL "Subject: Thank you for using 'my-mot.co.uk'\n\n";
print MAIL "This is to confirm that your vehicle details for $data{reg} have been added to our M.O.T. database\n\n";
print MAIL "You will receive reminders 28 days, 7 days & 1 day prior to your M.O.T. test date of $data{due_day}/$data{due_month}\n\n";
print MAIL "Please tell your friends, family & colleagues about this new site!\n\n";
print MAIL "close MAIL;[/red]

Firstly I really hope I haven't made any glaring errors and secondly I apologise for some poor references - but it should give an idea...

let me know how you get on!


Kind Regards
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top