3 recommendations:
  1. use CGI to handle all things forms
  2. use MIME::Lite to send the email
  3. use abstraction ... let Perl do the work
use strict; use warnings; use CGI::Pretty qw(:standard); use MIME::Lite; my @FIELD = qw( name email address1 address2 city state zip homephone workphone business goals comments ); print header; if (param('mail_it')) { my $data = join('', map "$_: " . param($_) . "\n", @FIELD); my $msg = MIME::Lite->new( From => 'webmaster@prowebdesigner.net', To => 'webmaster@prowebdesigner.net', Subject => 'Website Design Request', Data => $data, ); if ($msg->send) { print start_html('The Thank You'), p(' YOUR potential business is VERY IMPORTANT to PRO WEB DESIGN. We will respond as soon as we can. '), ; print p('Here is what you submitted:'), ul( li[map b("\u$_\E: ") . param($_), @FIELD]), ; } else { print start_html('The Oopsie'), p('whoops! something went wrong!'), } } else { print start_html('The Form'), start_form, (map "$_: ".textfield($_).br, @FIELD), submit('mail_it'), end_form, ; } print end_html;
I know that is a lot to grasp. But if you have the modules installed then by all means try it out. The benefit of this code is that each field name is only listed in the code once. Plus, the order that the fields are listed in is easily modified by changing the array @FIELD. Feel free to ask any questions. ;)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to CGI mailto via code reuse (AKA the CPAN) by jeffa
in thread Hand-rolled CGI mailto by prowebdesigner

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.