0
votes

I am using a formmail Perl script (Matt's script archive) from London Perl mongers to process several web forms I created. I have the script in the cgi-bin and it seems to be working; however the email output is just a long list with no formatting. I am working on the Perl script in Notepad and I am on a windows computer. I only did a few modifications to personalized the script for my client. I barely now anything about Perl. I have used this script before; but I don't know why the output is a long list with no formatting. I uploaded the script through the server's cpanel as I can't get it to ftp with my current ftp program. The server they are using is old and apparently insecure. I don't know if that makes a difference. How can I get the output to resemble a regular email and not just a list.

the email looks like this below:

Below is the result of your feedback form.  It was submitted by
hello () on Thursday, August 13, 2015 at 17:35:02
---------------------------------------------------------------------------
todayDate: 08/13/2015
ssn: 123456789
refer: self
birthdate: 08/02/2015
age: 32
gender1: Female
religion: yes
ethnicity: ethnic
address: 1234
city: big
state: CA
zip: 12345
homephone: 5105105100 32135684
workphone: 5105105100
cellphone: 5105105100
creditcard: na
nameOnCard: na
Occupation: work
employerName: hello there
employerAddress: 1234 street
employerCity: all city
employerState: CA
employerZip: 12345
education: BA Degree
inSchool2: No
marriedOrcommit: Yes
howLong: forever
namePartner: honey
occupationPartner: working hard
youPrev: none

I am using the following Perl script:

#!/usr/bin/perl -wT
#
# NMS FormMail Version 3.14c1
#

use strict;
use vars qw(
  $DEBUGGING $emulate_matts_code $secure %more_config
  $allow_empty_ref $max_recipients $mailprog @referers
  @allow_mail_to @recipients %recipient_alias
  @valid_ENV $date_fmt $style $send_confirmation_mail
  $confirmation_text $locale $charset $no_content
  $double_spacing $wrap_text $wrap_style $postmaster 
  $address_style
);

# PROGRAM INFORMATION
# -------------------
# FormMail.pl Version 3.14c1
#
# This program is licensed in the same way as Perl
# itself. You are free to choose between the GNU Public
# License <http://www.gnu.org/licenses/gpl.html>  or
# the Artistic License
# <http://www.perl.com/pub/a/language/misc/Artistic.html>
#
# For help on configuration or installation see the
# README file or the POD documentation at the end of
# this file.

# USER CONFIGURATION SECTION
# --------------------------
# Modify these to your own settings. You might have to
# contact your system administrator if you do not run
# your own web server. If the purpose of these
# parameters seems unclear, please see the README file.
#
BEGIN
{
  $DEBUGGING         = 1;
  $emulate_matts_code= 0;
  $secure            = 1;
  $allow_empty_ref   = 1;
  $max_recipients    = 2;
  $mailprog          = '/usr/lib/sendmail -oi -t';
  $postmaster        = '[email protected]';
  @referers          = qw(expressivehearts.com localhost);
  @allow_mail_to     = qw([email protected] localhost);
  @recipients        = ();
  %recipient_alias   = ();
  @valid_ENV         = qw(REMOTE_HOST REMOTE_ADDR REMOTE_USER  HTTP_USER_AGENT);
  $locale            = '';
  $charset           = 'iso-8859-1';
  $date_fmt          = '%A, %B %d, %Y at %H:%M:%S';
  $style             = '/public/css/jane.css';
  $no_content        = 0;
  $double_spacing    = 0;
  $wrap_text         = 0;
  $wrap_style        = 1;
  $address_style     = 0;
  $send_confirmation_mail = 0;
  $confirmation_text = <<'END_OF_CONFIRMATION';
From: [email protected]
Subject: New Client Forms Submission

Thank you for your submission.

END_OF_CONFIRMATION

# You may need to uncomment the line below and adjust the path.
# use lib './lib';

# USER CUSTOMISATION SECTION
# --------------------------
# Place any custom code here

# Email Header
print MAIL "To: $postmaster\n";
print MAIL "From: $realname\n";
print MAIL "Subject: $subject\n\n";
print MAIL "Content-type: text/html\n";




# USER CUSTOMISATION << END >>
# ----------------------------
# (no user serviceable parts beyond here)
}

#
# The code below consists of module source inlined into this
# script to make it a standalone CGI.

Please note: I only pasted a part of the Perl script as it is very long; it is supposed to be a standalone script.

1
This stuff is prehistoric and only really has the name in common with modern Perl. In short, don't use it any more. There are way better things around today. If you just want to collect form data for your client and you do not know about programming, consider using Google Forms. - simbabque
i can't use Google Forms; they are not secure and are not HIPAA compliant. - SylviaVanHorn
What does "How can I get the output to resemble a regular email and not just a list" mean? - Dave Cross

1 Answers

0
votes

The title to your question is "Perl script not processing html form correctly". I'm not sure what that means. In what way is formmail not processing the form correctly? It is taking all your form inputs and sending an email that contains all of the information. That is what it it supposed to do. It is working exactly as expected. It is not correct to say that it is not working correctly.

As simbabque says in his comment, this stuff really is antique and shouldn't be used any more. And I speak as the person who started the nms project. It's really only still there because otherwise there's a danger that people would gravitate back to Matt's scripts (Which are even worse!)

The original intention with the nms programs was that they reproduced what Matt's scripts did. So, yes, Formmail produces an unformatted list of its inputs. That's how things worked back then. I'm not really sure why anyone would need anything else.

If you really want formatted output from a 15-year-old CGI program, then look at the TFMail program from nms (http://nms-cgi.sourceforge.net/scripts.shtml) but, really, there are far better ways to do this these days.