Also, here's what I mean about eliminating repetition. It's untested though.

#!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; $CGI::POST_MAX = 1024 * 1; my %fields = ( fstname => [ first => 40 ], lstname => [ last => 40 ], adda => [ 1ad1a => 60 ], addb => [ 1ad1b => 60 ], city => [ 1ad2 => 60 ], state => [ 1ad3 => 20 ], zip => [ 1ad4 => 5 ], email => [ eadd => 70 ], phone => [ pnum => 16 ], residence => [ residence => 9 ], yardtype => [ yardtype => 16 ], yardtypeother => [ yardtypeother => 40 ], landlord => [ landlord => 40 ], preadda => [ 2ad1 => 60 ], precity => [ 2ad2 => 60 ], prestate => [ 2ad3 => 20 ], prezip => [ 2ad4 => 5 ], alone => [ alone => 14 ], household => [ household => 100 ], vet => [ vet => 45 ], pet => [ pet => 3 ], petname => [ petnme => 30 ], currentpets => [ currentpets => 60 ], previouspets => [ previouspets => 60 ], references => [ references => 140 ], ok => [ ok => 7 ], ); my %values; for my $key ( keys %fields ) { my ( $post_param, $max_length ) = @{ $fields{$key} } my $value = substr( param($post_param), 0, $max_length ); $value =~ s/[\|\/\\}{\[\]\(\)\*&\^%\$\#<>;:]/ /g; $values{$key} = $value; } $values{email} =~ tr/[A-Z]/[a-z]/; ## Check email address if ( $values{email} ne "" and $values{email} !~ /\@/ ) { print "Content-type: text/plain\n\n"; print "error (Your email is invalid, please check and resubmit you +r application)"; exit; } ## Check data my $total_form = $values{fstname} . $values{lstname} . $values{email}; if ( length($total_form) < 25 ) { print "Content-type: text/plain\n\n"; print "error (The form was incomplete, please check that you fille +d in your full first and last name, and email address, then resubmit +your application.)"; exit; } my $recipient = "email1\@emailsrv1, email2\@emailsrv2, email3\@emailsr +v3"; ## Create the email message body my $email_message = <<"MESSAGE" To: $values{recipient} Subject: Adoption Application From: $values{fstname} $values{lstname} <$values{email}> First name: $values{fstname} Last name: $values{lstname} Current address: $values{adda} $values{addb} $values{city} $values{state} $values{zip} _________________________________________________ Email address: $values{email} Phone number: $values{phone} Type of residence: $values{residence} Yard: $values{yardtype} Landlord contact info: $values{landlord} Previous address: $values{preadda} $values{precity} $values{prestate} $values{prezip} How many hours will pet be alone: $values{alone} Name and age of people in household: $values{household} Veterinarian: $values{vet} Dog or Cat: $values{pet} Name of pet requested: $values{petname} Current pets: $values{currentpets} Previous pets: $values{previouspets} References: $values{references} Aggree to consent form: $values{ok} MESSAGE ## Send email my $mailprog = '/usr/sbin/sendmail'; open my $mailhandle, '|-' "$mailprog -t" or die "Could not open mailhandle"; print $mailhandle $email_message; close $mailhandle; print "Location: application-submitted\n\n"; exit;

In reply to Re^3: sendmail working for me but not another by tobyink
in thread sendmail working for me but not another by kickingchicken

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.