Solved

Mailto on FORM

Posted on 1999-01-07
6
271 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
help with the script. not working for remote computers 3 63
exchange, scripts 3 60
Need some help in Batch file assigning variable value ? 4 66
copy-item script help 15 66
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to dynamically set the form action using jQuery.

912 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

22 Experts available now in Live!

Get 1:1 Help Now