Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Mailto on FORM

Posted on 1999-01-07
6
Medium Priority
?
323 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 600 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
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 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 …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

604 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