P
PF
I have a web page that posts its form data to a cgi script.
I have a request to modify the perl script to BCC the raw form data to
a separate email address. I thought I could just BCC the data as shown
below but the email that gets sent is parsed out into field names and
values. I do not need to change that part. I just need the raw form
data from the HTML post to get emailed to a second email address. I
know this should be easy but I have never programmed PERL and haven't
a clue.
Any resources that show how to do this.
Paul
There is a send mail function like this:
sub send_mail {
# Localize variables used in this subroutine.
#
local($print_config,$key,$sort_order,$sorted_field,$env_report);
# Open The Mail Program
open(MAIL,"|$mailprog -t");
print MAIL "To: webleads\@MyDomain.com\n";
print MAIL "From: $Config{'email'} ($Config{'Name'})\n";
print MAIL "cc: \n";
print MAIL "Bcc: demorequest\@MyDomain.net\n";
# Check for Message Subject
if ($Config{'subject'}) { print MAIL "Subject:
$Config{'subject'}\n\n" }
else { print MAIL "Subject: WWW Form
Submission\n\n" }
print MAIL "Demo Request\n";
print MAIL "$date at $time\n";
print MAIL "Host: $ENV{'REMOTE_ADDR'}\n";
print MAIL "-" x 55 . "\n\n";
print MAIL "Name: $Config{'Name'}\n\n";
print MAIL "Email: $Config{'email'}\n\n";
if (@Print_Config) {
foreach $print_config (@Print_Config) {
if ($Config{$print_config}) {
print MAIL "$print_config:
$Config{$print_config}\n\n";
}
}
}
# Sort alphabetically if specified:
#
if ($Config{'sort'} eq 'alphabetic') {
foreach $field (sort keys %Form) {
# If the field has a value or the print blank fields
option #
# is turned on, print out the form field and value.
#
if ($Config{'print_blank_fields'} || $Form{$field} ||
$Form{$field} eq '0') {
print MAIL "$field: $Form{$field}\n\n";
}
}
}
# If a sort order is specified, sort the form fields based on
that. #
elsif ($Config{'sort'} =~ /^order:.*,.*/) {
# Remove extraneous line breaks and spaces, remove the order:
#
# directive and split the sort fields into an array.
#
$Config{'sort'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'sort'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'sort'} =~ s/order://;
@sorted_fields = split(/,/, $Config{'sort'});
# For each sorted field, if it has a value or the print blank
#
# fields option is turned on print the form field and value.
#
foreach $sorted_field (@sorted_fields) {
if ($Config{'print_blank_fields'} || $Form{$sorted_field}
||
$Form{$sorted_field} eq '0') {
print MAIL "$sorted_field: $Form{$sorted_field}\n\n";
}
}
}
# Otherwise, default to the order in which the fields were sent.
#
else {
# For each form field, if it has a value or the print blank
#
# fields option is turned on print the form field and value.
#
foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field} ||
$Form{$field} eq '0') {
print MAIL "$field: $Form{$field}\n\n";
}
}
}
print MAIL "-" x 65 . "\n\n";
# Send any specified Environment Variables to recipient.
#
foreach $env_report (@Env_Report) {
if ($ENV{$env_report}) {
print MAIL "$env_report: $ENV{$env_report}\n";
}
}
close (MAIL);
}
I have a request to modify the perl script to BCC the raw form data to
a separate email address. I thought I could just BCC the data as shown
below but the email that gets sent is parsed out into field names and
values. I do not need to change that part. I just need the raw form
data from the HTML post to get emailed to a second email address. I
know this should be easy but I have never programmed PERL and haven't
a clue.
Any resources that show how to do this.
Paul
There is a send mail function like this:
sub send_mail {
# Localize variables used in this subroutine.
#
local($print_config,$key,$sort_order,$sorted_field,$env_report);
# Open The Mail Program
open(MAIL,"|$mailprog -t");
print MAIL "To: webleads\@MyDomain.com\n";
print MAIL "From: $Config{'email'} ($Config{'Name'})\n";
print MAIL "cc: \n";
print MAIL "Bcc: demorequest\@MyDomain.net\n";
# Check for Message Subject
if ($Config{'subject'}) { print MAIL "Subject:
$Config{'subject'}\n\n" }
else { print MAIL "Subject: WWW Form
Submission\n\n" }
print MAIL "Demo Request\n";
print MAIL "$date at $time\n";
print MAIL "Host: $ENV{'REMOTE_ADDR'}\n";
print MAIL "-" x 55 . "\n\n";
print MAIL "Name: $Config{'Name'}\n\n";
print MAIL "Email: $Config{'email'}\n\n";
if (@Print_Config) {
foreach $print_config (@Print_Config) {
if ($Config{$print_config}) {
print MAIL "$print_config:
$Config{$print_config}\n\n";
}
}
}
# Sort alphabetically if specified:
#
if ($Config{'sort'} eq 'alphabetic') {
foreach $field (sort keys %Form) {
# If the field has a value or the print blank fields
option #
# is turned on, print out the form field and value.
#
if ($Config{'print_blank_fields'} || $Form{$field} ||
$Form{$field} eq '0') {
print MAIL "$field: $Form{$field}\n\n";
}
}
}
# If a sort order is specified, sort the form fields based on
that. #
elsif ($Config{'sort'} =~ /^order:.*,.*/) {
# Remove extraneous line breaks and spaces, remove the order:
#
# directive and split the sort fields into an array.
#
$Config{'sort'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
$Config{'sort'} =~ s/(\s+)?\n+(\s+)?//g;
$Config{'sort'} =~ s/order://;
@sorted_fields = split(/,/, $Config{'sort'});
# For each sorted field, if it has a value or the print blank
#
# fields option is turned on print the form field and value.
#
foreach $sorted_field (@sorted_fields) {
if ($Config{'print_blank_fields'} || $Form{$sorted_field}
||
$Form{$sorted_field} eq '0') {
print MAIL "$sorted_field: $Form{$sorted_field}\n\n";
}
}
}
# Otherwise, default to the order in which the fields were sent.
#
else {
# For each form field, if it has a value or the print blank
#
# fields option is turned on print the form field and value.
#
foreach $field (@Field_Order) {
if ($Config{'print_blank_fields'} || $Form{$field} ||
$Form{$field} eq '0') {
print MAIL "$field: $Form{$field}\n\n";
}
}
}
print MAIL "-" x 65 . "\n\n";
# Send any specified Environment Variables to recipient.
#
foreach $env_report (@Env_Report) {
if ($ENV{$env_report}) {
print MAIL "$env_report: $ENV{$env_report}\n";
}
}
close (MAIL);
}