Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"print SENDMAIL" to write all selections from @CATALOG array

Status
Not open for further replies.

tomsweb

Programmer
Jul 24, 2003
4
US
I have coded a PERL script to send email to a sales rep. with customer catalog order and US Mailing information.
The customer selects to receive any of several catalogs at current online Web site Order Form.

Based on the customer's inputted zip code, a specific sales rep. will get this personal and catlog order information via email message.

I cannot get "print SENDMAIL" to write all catalog selections from @CATALOG array.

Can anyone offer assistance?

#!/usr/bin/perl
######################################
# Harvest Group Marketing Associates #
# Catalog Order Script #
######################################
#
# Create the CGI Object
#
use CGI;
my $q = new CGI;

#
# Output the HTTP Header
#
print "Content-type:text/html\n\n";

######################################
# Set up the variables #
######################################
@CATALOG = $q->param('Catalog');
$name = $q->param('Name');
$company = $q->param('Title');
$email1 = $q->param('Email');
$cc = $q->param('cc_mail');

my $zip = $q->param('Zip');
my $recipient = zipmail($zip);
my $sendmailpath = "/usr/sbin/sendmail -t";
my $subject = "Catalog Order Request";

###################################
# Match User Zip Codes to get $recipient e-mail
###################################
sub zipmail($) {
if($zip == '17705') {$recipient="tom_fitzsimmons\@micro-link.net";}
elsif(($zip >='17701') && ($zip <= '17799')) {$recipient=&quot;cookies\@micro-link.net&quot;;}
else {$recipient=&quot;mikeshaf\@ptd.net&quot;;}
}

####################################################
# Send email to customer to confirm Catalog Order #
####################################################
open(SENDMAIL, &quot;¦$sendmailpath&quot;) or die &quot;Cannot open $sendmail: $!&quot;
print SENDMAIL &quot;From: $email1\n&quot;;
print SENDMAIL &quot;To: $recipient\n&quot;;
print SENDMAIL &quot;BCC: $cc\n&quot;;
print SENDMAIL &quot;Subject: $subject\n\n&quot;;
print SENDMAIL &quot;Thanks, $name for your order!\n\n&quot;;
print SENDMAIL &quot;You have ordered:\n&quot;;
print SENDMAIL &quot;<ul>&quot;;
foreach $CATALOG (@CATALOG) { print SENDMAIL &quot;<li>$CATALOG \n&quot;; }
print SENDMAIL &quot;</ul>&quot;;
print SENDMAIL &quot;\n\n&quot;;
print SENDMAIL &quot;In Christ,\n\n&quot;;
print SENDMAIL &quot;-Harvest Group MA &quot;;
close (SENDMAIL);
&thank_you;
#########################################################
# Redirect the Browser Page using unordered list &quot;<ul></ul>&quot; #
#########################################################
sub thank_you {

print &quot;<html>&quot;;
print &quot;<head><title>Order Confirmation</title></head>&quot;;
print &quot;<body bgcolor=#800000>&quot;;
print &quot;<font face=Tempus Sans ITC color=white><h2>Thanks, $name for your order!</h2></font>&quot;;
print &quot;<font face=Tempus Sans ITC color=white><h3>On behalf of $company, $name has ordered:&quot;;
print &quot;<ul>&quot;;
foreach $CATALOG (@CATALOG) { print &quot;<li>$CATALOG \n&quot;; }
print &quot;</ul>&quot;;
print &quot;These catalogs will be shipped within two business days.</h3>&quot;;
print &quot;<b>An e-mail confirmation has been sent to</FONT><FONT COLOR=#DAA520> $recipient</FONT>
<font face=Tempus Sans ITC color=white> in zip code:</FONT> <FONT COLOR=#DAA520>$zip.</b></font><br>&quot;;
print &quot;</body>&quot;;
print &quot;</html>&quot;;
exit(0);
}

Thanks!
Tomsweb
 
You need to set the content type to html.

print SENDMAIL &quot;Subject: $subject\n\n&quot;;
print SENDMAIL qq~Content-Type: text/html\n\n~;
print SENDMAIL &quot;Thanks, $name for your order!\n\n&quot;;
 
@CATALOG = $q->param('Catalog');

How are you passing this array back from your form/script?

--Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top