Solved

Mailto on FORM

Posted on 1999-01-07
6
265 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 to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
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…
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…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

760 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

20 Experts available now in Live!

Get 1:1 Help Now