Solved

Mailto on FORM

Posted on 1999-01-07
6
278 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Update a registry value to every user hive 15 81
How can i reset all images size to default in a word file 6 68
Folder Permission Powershell 4 56
Where do I learn ES6? 3 66
In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now