$mailprog = '/usr/lib/sendmail -i -t -f www@domain.com'; 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"); print MAIL "To: $Config{'recipient'}\n"; print MAIL "From: $Config{'email'} ($Config{'realname'})\n"; # Check for Message CC and/or BCC field if ($Config{'cc'}) { print MAIL "CC: $Config{'cc'}\n" } if ($Config{'bcc'}) { print MAIL "BCC: $Config{'bcc'}\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 "Below is the result of your feedback form. It was submitted by\n"; print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n"; print MAIL "-" x 75 . "\n\n"; if (@Print_Config) { foreach $print_config (@Print_Config) { if ($Config{$print_config}) { print MAIL "$print_config: $Config{$print_config}\n\n"; } } } # If a sort order is specified, sort the form fields based on that. # if ($Config{'sort'} =~ /^order:.*,.*/) { # Remove extraneous line breaks and spaces, remove the order: # # directive and split the sort fields into an array. # local $sort_order = $Config{'sort'}; $sort_order =~ s/(\s+|\n)?,(\s+|\n)?/,/g; $sort_order =~ s/(\s+)?\n+(\s+)?//g; $sort_order =~ s/order://; @sorted_fields = split(/,/, $sort_order); # 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} ne '') { print MAIL "$sorted_field: $Form{$sorted_field}\n\n"; } } } # Otherwise, print fields in order they were sent or alphabetically. # else { # Sort alphabetically if specified: # if ($Config{'sort'} eq 'alphabetic') { @Field_Order = sort @Field_Order; } # 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} ne '') { print MAIL "$field: $Form{$field}\n\n"; } } } print MAIL "-" x 75 . "\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);