All in the following code snippet - I have this code working without syntax error if a user accesses the page directly they get the message listed in the else statement "This page cannot be accessed directly " - and when the user accesses the page from a post method it e-mail it to the proper e-mail box. However what doesn't show up in the e-mail is any of the variables - example: $order $subtotal $promo $tax $shipping $total - so I get the e-mail but it doesn't have any of the values from my form - so therefore am I missing a bracket or need some other logic change so the e-mail has my variables: 


$to = "orderemail\";
$date = todays-date;


sub Email {
open (MAIL, "| /usr/sbin/sendmail "
      . "-F\" $name\" "
      . "-f\" $email\" "
      . "$to" )
    || die "x\n\n(*)Sendmail returned error code. Halting. \n\n";
$header = "Date: $date\n"
    . "To: $to\n"
    . "Subject: New Order\n\n";

$message .= "ITEM     DESIGN   DESCRIP.              QUAN. PRICE EA.\n";
$message .= "-------------------------------------------------------\n";
$message .= "$order\n\n";
$message .= " subtotal: $subtotal\n";
$message .= "    promo: $promo PROMOTIONAL PRICE\n";
$message .= "sales tax: $tax\n";
$message .= " shipping: $shipping\n";
$message .= "    TOTAL: $total\n\n";

print MAIL "$header";
print MAIL "$message";


sub Thanks {
open (MAIL, "| /usr/sbin/sendmail "
      . "-F\" $to\" "
      . "-f\" $to\" "
      . "$email" )
    || die "x\n\n(*)Sendmail returned error code. Halting. \n\n";
$header2 = "Date: $date\n"
    . "To: $email\n"
    . "Subject: promo confirmation\n\n";

$message2 .= "-------------------------------------------------------\n";
$message2 .= "Thank you for your order! Your item will ship tomorrow via the USPS. \n\n";
$message2 .= "-------------------------------------------------------\n";
print MAIL "$header2";
print MAIL "$message2";


sub HTML {
print << "EndOfHTML";

<TITLE>Promo Order</TITLE>
<BODY BGCOLOR="#ffffff" BACKGROUND="../../images/yellowBarBG.gif" LINK="#000000" ALINK="#bb0000" VLINK="#000000">
<TR VALIGN="top">
    <TD WIDTH="150" ALIGN="left">
<FONT SIZE=1>Promos</FONT><BR>
<U><B>P R O M O<BR>C O M P L E T E</B></U><BR>
Thank you for placing your promo with us!
<A HREF="/">return to front page</A>
<TD WIDTH="50">&nbsp;&nbsp;</TD>
<TD WIDTH="400">



} else { 

print "This page cannot be accessed directly";



You need to get the parameters for post params before you can use them in your email template.
Suppose that you have {name, email, order, subtotal, promo, tax, shipping, total} fields in your form, you need to write code like below before making MAIL call :

my $query = new CGI;

my $name = $query->param('name');
my $email = $query->param('email');
my $order = $query->param('order');
my $subtotal = $query->param('subtotal');
my $promo = $query->param('promo');
my $tax = $query->param('tax');
my $shipping = $query->param('shipping');
my $total = $query->param('total');
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.