Here's the code:

#!/usr/bin/perl -w ###use strict; use DBI; use CGI qw(:standard); print "Content-type: text/html\n\n"; @referers = ('72.167.40.203','www.mywebsite.com','mywebsite.com'); &check_url; &mail; sub check_url { local($check_referer) = 0; if ($ENV{'HTTP_REFERER'}) { foreach $referer (@referers) { if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) +{ $check_referer = 1; last; } } } else { $check_referer = 1; } if ($check_referer != 1) {&bad_referer} } sub bad_referer { print "content-type: text/html\n\n"; print <<"(END ERROR HTML)"; <html> <head> <title>Bad Referrer - Access Denied</title> </head> <body bgcolor=#FFFFFF text=#000000> <center> <table border=0 width=600 bgcolor=#9C9C9C> <tr><th><font size=+2>Bad Referrer - Access Denied</font></th></tr +> </table> </center> </body> </html> (END ERROR HTML) exit; } sub mail { ###Get the name, email address, and profile address of the sender my ($dbh, $sth, $count, $AccountID,$SenderFirstName, $SenderLastName, +$SenderEmail, $ID, $row, $View); $dbh = DBI->connect('dbi:mysql:membersdb','ID','pw') or die "Connection Error: $DBI::errstr\n"; my $SenderID = param('SenderID'); $sth = $dbh->prepare("SELECT FirstName,LastName,Email,View FROM member +info WHERE AccountID='$SenderID'"); $sth->execute (); my @row = $sth->fetchrow_array (); $SenderFirstName= $row[0]; $SenderLastName= $row[1]; $SenderEmail= $row[2]; $SenderView= $row[3]; $sth->finish; ##Get the name & email address of the recipient my ($dbh, $sth, $count, $AccountID,$FirstName, $LastName, $Email, $row +); $dbh = DBI->connect('dbi:mysql:membersdb','ID','pw') or die "Connection Error: $DBI::errstr\n"; my $ID = param('AccountID'); $sth = $dbh->prepare("SELECT FirstName,LastName, Email FROM memberinfo + WHERE AccountID='$ID'"); $sth->execute (); my @row = $sth->fetchrow_array (); $FirstName= $row[0]; $LastName= $row[1]; $Recipient= $row[2]; $sth->finish; $dbh->disconnect (); use HTML::Entities; use Mail::Sendmail 0.79; my $Message = param('Message'); $From="info\@mywebsite.com"; $html = <<END_HTML; <p>$SenderFirstName $SenderLastName has sent you a message.</p> <p>$Message</p> <form method="POST" action="http://www.mywebsite.com/cgi-bin/global/cr +eate_reply_mail_htm.pl?ID=$SenderID"> <p>Reply to $SenderFirstName --- <input type="submit" value="REPLY" na +me="B1" style="color: #FFFFFF; background-color: #0000FF"> </p> </form></p> END_HTML %mail = ( from => "$From", to => "$Recipient", subject => 'A Message From My Website', 'content-type' => 'text/html; charset="iso-8859-1"', ); $mail{body} = <<END_OF_BODY; <html>$html</html> END_OF_BODY sendmail(%mail) || print "Error: $Mail::Sendmail::error\n"; ###} &redirect; exit (0); sub redirect { print "Your Message Was Sent\n\n"; } exit; }
$FROM is a constant so the '@' sign was simply escaped with a \. Other variables are sent from forms and everything works fine with the above code with the param function. I do have another question. Where do I find information as to how to get CGI.pm to accept either POST or GET methods? Is there a smidgen of code to use?

In reply to Re^4: MAIL::SENDMAIL - Inserting $variable Into TO or FROM? by Milti
in thread MAIL::SENDMAIL - Inserting $variable Into TO or FROM? by Milti

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.