can you be a bit more specific as to what you are attempting to do? You want all the results of a form submitted included in an email of some sort ??
Mickalo
__________________
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing
Providing Internet Solutions that work!
Custom Perl Programming & MySQL designs
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
I would like for the person filling out the form to be able to type in their email address in specified field so that they will also receive the results of their form. I have a hidden "mail_to" input type that sends the form to me, but I also want the user to also be able to receive the form submission by sending the results to the email address they typed in.
Hope this better explains. I would really appreciate help with this. Im just begining my journey in web development.
I would like for the person filling out the form to be able to type in their email address in specified field so that they will also receive the results of their form. I have a hidden "mail_to" input type that sends the form to me, but I also want the user to also be able to receive the form submission by sending the results to the email address they typed in.
Hope this better explains. I would really appreciate help with this. Im just begining my journey in web development.
without actually seeing the script your using, it's difficult to determine the best way to do this. But I assume your scripts sends you the email via 'sendmail' or other means to email you the form submission. It would be a matter of CC'ing the form submission to the person's email address filling out the form or sending a separate email to that person.
Is this a Perl written script? Can you post the script somewhere so it could be looked at?
Mickalo
__________________
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Thunder Rain Internet Publishing
Providing Internet Solutions that work!
Custom Perl Programming & MySQL designs
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Here is the html opening of my form:
<form method="post" action="/cgi-bin/mailer.pl">
<input type="hidden" name="mail_to" value="myname@myaddress.com" />
<input type="hidden" name="mail_subject" value="Form Submission" />
<input type="hidden" name="mail_redirect" value="/testform/" />
<input type="hidden" name="mail_redirect_message" value="Thank you... />
Here is mailer.pl file:I received this file from a classmate. Maybe its possible to do what I want, but am unsure. Again Im just getting in development.
#!/usr/bin/perl
=pod
Mailer.pl will e-mail the contents of a web form.
The values of all named inputs are sent with the exception of the special input names listed below.
Inputs that mailer will recognize as special are:
mail_to
mail_from
mail_subject
mail_redirect
mail_redirect_message
mail_sysdate
mail_required
The value of mail_to specifies the e-mail address to send the contents of the form to.
If the first character of mail_to is a \ then it uses the value of the input named after the \.
If a \ is used, the named input must exist and must submit a value.
Multiple e-mail addresses in one mail_to must be separated by commas.
A default_to should be specified in the Default Settings section, otherwise mail_to must be in the form.
The value of mail_from is sent as the from and reply-to address in messages sent by mailer.
A default_from may be specified in the Default Settings section, otherwise mail_from must be in the form.
The value of mail_subject is sent as the subject line in the message.
A default_subject may be specified in the Default Settings section.
The value of mail_redirect is used to redirect the browser to a page after the form is submitted.
The value of mail_redirect_message is displayed on the screen before the browser is redirected to mail_redirect.
The value of mail_sysdate is used to display the system date in the body of the message.
The value of mail_required is used to specify input names that must contain values when submitted.
There may be multiple mail_required inputs, or one that specifies all the required input names (but not both!).
Multiple input names in one mail_required must be separated by commas.
Required Settings:
@referers must contain a list of all the sites allowed to use mailer.
(This must be the name used by browsers to connect to the site hosting the form.)
@recipient_domains must contain a list of all the domains mailer is allowed to send to.
(Entries must all start with @ and be complete.)
$mail_admin should contain the e-mail address for users to send any error messages to.
Default Settings:
This section supplies the default settings for values not supplied by the form.
=cut
# Required Settings #
#@referers = qw(____ );
@recipient_domains = qw(@_______;
$mail_admin = '__';
# End Required Settings #
# Default Settings #
$default_to = "$mail_admin";
$default_from = "$mail_admin";
$default_subject = "$ENV{HTTP_REFERER}";
$default_redirect = "$ENV{HTTP_REFERER}";
# End Default Settings #
use CGI;
#foreach $referer (@referers) {
# $OK = 1 if($ENV{HTTP_REFERER} =~ m|^https?://$referer/|);
#}
#push(@error,"SECURITY ERROR: HTTP_REFERER $ENV{HTTP_REFERER} NOT ALLOWED!<BR>") if(! $OK);
@required = CGI::param('mail_required');
foreach (CGI::param) {
$Form{$_} = CGI::param($_);
push @keys,$_;
}
delete $Form{mail_required};
if (scalar @required == 1) {
@required = split(/,/,$required[0]);
}
foreach (@required) {
push(@error,"$_<BR>") if($_ and ! $Form{$_});
}
if($Form{mail_to}) { $to = delete $Form{mail_to}; }
else { $to = $default_to; }
if($Form{mail_from}) { $from = delete $Form{mail_from}; }
else { $from = $default_from; }
if($Form{mail_subject}) { $subject = delete $Form{mail_subject}; }
else { $subject = $default_subject; }
if($Form{mail_redirect}) { $redirect = fix_redirect(delete $Form{mail_redirect}); }
else { $redirect = $default_redirect; }
if($Form{mail_sysdate}) { $sysdate = delete $Form{mail_sysdate}; $Form{$sysdate} = localtime; }
if($from =~ s/^\\//) { $from = delete $Form{$from}; }
if($to =~ s/^\\//) { $to = delete $Form{$to}; }
$redirect_message = delete $Form{mail_redirect_message};
$redirect_seconds = int(length($redirect_message) / 10);
foreach (split(/(,|\s)/,$to)) {
next if ($_ =~ /[^\w\.\@]/);
$_ =~ /(@.*)/;
push(@to,$_) if (grep(/$1/,@recipient_domains));
}
$to = join(' ',@to);
$from =~ s/[\r\n]//g; # Remove newlinessneaking mail through us
$subject =~ s/[\r\n\@]//g; # Remove newlines and any "@" symbols
push(@error,"mail_from<BR>") if(! $from);
push(@error,"mail_to<BR>") if(! $to);
if(@error) { returnError(); }
else { sendMail(); }
sub returnError {
print <<EOP
Content-type: text/html
<html><head><title>Error</title></head><body>
The following fields were left blank in the submitted form:<BR><b>@error</b>
These fields must be filled in before you can successfully submit the form.<BR>
Please use your browser's Back button to return to the form and try again.<P>
If you have any questions about the above error message,
please send the complete error message to
<a mailto:$mail_admin>$mail_admin</a>
</body></html>
EOP
;
} # end sub return_error
sub sendMail{
foreach $key (@keys) {
$keyname = $key; $keyname =~ tr/+/ /;
$keyname =~ s/%([a-fA-F0-9][a-fA-F0-9])/chr(hex($1))/eg;
push(@MAIL,"$keyname: $Form{$key}\n\n") if($Form{$key});
}
$lt = localtime;
open MAIL, "|/usr/sbin/sendmail -t";
print MAIL "From:$from\nTo:$to\nSubject:$subject\nDate:$lt\n\n@MAIL";
close MAIL;
print "Refresh: $redirect_seconds;URL=$redirect\nContent-type: text/html\n\n$redirect_message";
} # end sub sendMail
sub fix_redirect {
#Fix paths that are relative to the referer.
my $refer = $ENV{HTTP_REFERER};
my $redir = $_[0];
return $redir if $redir =~ m"^(https?://|/)";
$refer =~ s"[^/]*$"";
return $refer.$redir;
}