Perl脚本无法正确处理html表单

时间:2015-08-17 04:01:04

标签: html forms perl email cgi

我正在使用来自London Perl mongers的formmail Perl脚本(Matt的脚本档案)来处理我创建的几个Web表单。我在cgi-bin中有脚本,它似乎正在工作;但是电子邮件输出只是一个没有格式的长列表。我在记事本中处理Perl脚本,我在Windows计算机上。我只对我的客户端的个性化脚本做了一些修改。我现在几乎没有关于Perl的任何信息。我以前用过这个剧本;但我不知道为什么输出是一个没有格式的长列表。我通过服务器的cpanel上传了脚本,因为我无法使用当前的ftp程序将其下载到ftp。他们使用的服务器很旧,显然不安全。我不知道这是否有所作为。如何使输出类似于常规电子邮件,而不仅仅是列表。

电子邮件如下所示:

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

我正在使用以下Perl脚本:

#!/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        = 'sylviavanhorn@gmail.com';
  @referers          = qw(expressivehearts.com localhost);
  @allow_mail_to     = qw(sylviavanhorn@gmail.com 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: expressivehearts@gmail.com
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.

请注意:我只粘贴了Perl脚本的一部分,因为它很长;它应该是一个独立的脚本。

1 个答案:

答案 0 :(得分:0)

您问题的标题是“Perl脚本未正确处理html表单”。我不确定这意味着什么。 formmail以什么方式不能正确处理表单?它将获取所有表单输入并发送包含所有信息的电子邮件。这就是它应该做的。它完全按预期工作。说它不能正常工作是不正确的。

正如simbabque在评论中所说,这些东西真的很古老,不应再使用了。我作为启动nms项目的人发言。它真的只是在那里,因为否则会有一种危险,人们会重新回到马特的剧本(更糟糕的是!)

nms程序的初衷是他们重现了Matt的脚本所做的事情。所以,是的,Formmail会生成一个未格式化的输入列表。这就是当时的事情。我不确定为什么有人会需要其他任何东西。

如果你真的想要一个有15年历史的CGI程序的格式化输出,那么从nms(http://nms-cgi.sourceforge.net/scripts.shtml)看一下TFMail程序,但实际上,现在有更好的方法可以做到这一点。 / p>