Help Desk Form submission from
(address1@private.com) on Wednesday, February 01, 2006 at 09:23:42
Organization:
Phone: () - Ext:
---------------------------------------------------------------------------
Message:
---------------------------------------------------------------------------
firstname: eric
organization: org1
lastname: primmer
verifyemail: eprimmer@mindandmedia.com
phone: 222
phone2: 222
phone3: 2222
message: this email should go to agency1 email address
privacy: checkbox
Submit: Submit
---------------------------------------------------------------------------
#!/usr/bin/perl -wT
#
# NMS FormMail Version 3.14c1
#
.
.
.
# PROGRAM INFORMATION
# -------------------
# FormMail.pl Version 3.14c1
.
.
.
BEGIN
{
$DEBUGGING = 1;
$emulate_matts_code= 0;
$secure = 1;
$allow_empty_ref = 1;
$max_recipients = 2;
$mailprog = '/usr/lib/sendmail -oi -t';
$postmaster = 'address@agency.mil';
@referers = qw(sub.agency.mil localhost);
@allow_mail_to = ();
@recipients = ();
%recipient_alias = (
'Feedback' => 'helpdesk@agency.mil',
'Initiative' => 'helpdesk@agency.mil',
'Training' => 'helpdesk@agency.mil',
'Other' => 'helpdesk@agency.mil',
'Accountability' => 'address2@agency2.mil',
'Support' => 'Websupport@private.com',
);
@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 = '/css/nms.css';
$no_content = 0;
$double_spacing = 1;
$wrap_text = 0;
$wrap_style = 1;
$address_style = 0;
$send_confirmation_mail = 0;
$confirmation_text = <<'END_OF_CONFIRMATION';
.
.
.
sub send_main_email_body_header {
my ($self, $date) = @_;
my $dashes = '-' x 75;
$dashes .= "\n\n" if $self->{CFG}{double_spacing};
$self->mailer->print(<<END);
Agency Help Desk Form submission from
$self->{FormConfig}{firstname} $self->{FormConfig}{lastname}($self->{FormConfig}{email}) on $date
$self->{FormConfig}{subject} $self->{FormConfig}{recipients}
Organization: $self->{FormConfig}{organization}
Phone: ($self->{FormConfig}{phone}) $self->{FormConfig}{phone2} - $self->{FormConfig}{phone3} Ext: $self->{FormConfig}{phone4}
$dashes
Message: $self->{FormConfig}{message}
$dashes
END
}
.
.
.
Please help!
I was also confused that I was seeing my form values appear later in the email. This is apparently happening later in the formmail code. I'd actually still like advice on getting rid of the standard section of the formmail email that prints each of the form variables. I don't need this section now that I have included these values in body copy of my email header.
Anyone no how to get rid of this?
sub send_main_email_body_header {
my ($self, $date) = @_;
my $dashes = '-' x 75;
$dashes .= "\n\n" if $self->{CFG}{double_spacing};
$self->mailer->print(<<END);
Agency Help Desk Form submission from
$self->{FormConfig}{firstname} $self->{FormConfig}{lastname}($self->{FormConfig}{email}) on $date
$self->{FormConfig}{subject} $self->{FormConfig}{recipients}
Organization: $self->{FormConfig}{organization}
Phone: ($self->{FormConfig}{phone}) $self->{FormConfig}{phone2} - $self->{FormConfig}{phone3} Ext: $self->{FormConfig}{phone4}
$dashes
Message: $self->{FormConfig}{message}
$dashes
END
}
Well, here is the formmail code which i use personally for getting a nice formated table content.
If you are looking for formatting email then this is it.
#!/usr/bin/perl
$recipient = 'me@domain.com';
$redirect = 'http://domain.com/thankyou.htm';
$mailprog = '/usr/lib/sendmail -t';
&parse_form;
&send_mail;
&redirect;
sub parse_form {
%Config = ('realname','', 'email','', 'subject','', 'comment','');
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/, $ENV{'QUERY_STRING'});
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
}
else {
&error('request_method');
}
foreach $pair (@pairs) {
local($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/\0//d;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/\0//d;
if (defined($Config{$name})) {
$Config{$name} = $value;
}
else {
if ($Form{$name} ne '') {
$Form{$name} = "$Form{$name}, $value";
}
else {
push(@Field_Order,$name);
$Form{$name} = $value;
}
}
}
}
sub send_mail {
open(MAIL,"¦ $mailprog");
print MAIL "To: $recipient\n";
print MAIL "From: $Config{'email'} ($Config{'realname'})\n";
print MAIL "Content-Type: text/html\n";
print MAIL "Subject: $Config{'subject'}\n";
print MAIL <<_MAIL_;
<table border="0">
<tr> <td>Name</td> <td>: $Config{'realname'}</td> </tr>
<tr> <td>Email</td> <td>: $Config{'email'}</td> </tr>
<tr> <td valign="top">Suggestion</td><td>: $Config{'comment'} <br><br></td> </tr>
</table>
_MAIL_
close (MAIL);
}
sub redirect {
print "Location: $redirect\n\n";
}