Solved

Mailto on FORM

Posted on 1999-01-07
6
286 Views
Last Modified: 2013-12-25
I have a form that sends the result to a CGI program to verify the accuracy of the results.  I'd also like to mail that form that the cgi program gets.

How do I get the submitted from to go two places, the cgi program and to a mail recipient?
0
Comment
Question by:chonsp
6 Comments
 
LVL 7

Expert Comment

by:yoren
ID: 1830513
Have the CGI program mail the form if it's accurate. What platform/language are you using for your CGI?
0
 

Author Comment

by:chonsp
ID: 1830514
Perl 5 script under Solaris.

Since I am using POST, the CGI scitp gets all its values as PARM1="LAST NAME"&PARM2="FIRST NAME".  How do I automatically thread all this into the body of a mail and send it off.  Normally mailto just pulls up a mail window witht he recipient filled in.
0
 
LVL 8

Expert Comment

by:jhurst
ID: 1830515
By much better for the cgi to do the eMail, then you know that it really got there.  It also solves the problem of multiple submission requests from one submit button.
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

Author Comment

by:chonsp
ID: 1830516
So you're saying do not use mailto but an underlying mail command available on my webserver?
0
 
LVL 1

Accepted Solution

by:
sdjjm earned 150 total points
ID: 1830517
Don't use "mailto", use "sendmail", a program which should be available on your server which you can access from your CGI.   Parse the output from your POST form into string values within your CGI, and direct it to sendmail with a subroutine like the one below.
Here's a very basic Perl CGI which will take the data from your form, store it in the array named @value, and send output to sendmail which will generate/send your email.  You'll need to determine which string in @value contains the email address you want to send email to,  change the other string values to whatever you want, and locate the sendmail program on your server...

#!/usr/bin/perl
### Script Body ###
&parse;
$to=$value[0];         #change $value[number] to where the email address is in @value
$from="your@email-address";
$errors="your@email-address";
$subject="whatever you want";
$copy="address@to-send-copy-to";
$text="put message body here";
&email;
exit;
### Subroutines ###
sub parse {
read(STDIN,$user_string,$ENV{'CONTENT_LENGTH'});
if (length($ENV{'QUERY_STRING'})>0) {$user_string=$ENV{'QUERY_STRING'}};
$user_string =~ s/\+/ /g;
@name_value_pairs = split(/&/,$user_string);
foreach $name_value_pair (@name_value_pairs) {
        ($keyword,$value) = split(/=/,$name_value_pair);
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge;
        push(@value, "$value");
        $user_data{$keyword} = $value;
        };
};
sub email {
open(MAIL, "|/usr/lib/sendmail -t");    #must have correct path to sendmail on your server
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Errors-To: $errors\n";
print MAIL "Subject: $subject\n";
print MAIL "cc: $copy\n";
print MAIL "$text\n";        
close(MAIL);
return;
};

0
 

Author Comment

by:chonsp
ID: 1830518
Looks good.  I have'nt implemented yet but I think that will do the trick.  Thanks.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question