#!/usr/bin/perl
use CGI::Carp qw{fatalsToBrowser};
##############################################################################
# Software download Version 1.0 #
##############################################################################
# ------------------------------------------------------------
# Form-mail.pl, by Reuven M. Lerner (reuven@the-tech.mit.edu).
#
# Last updated: March 14, 1994
#
# Form-mail provides a mechanism by which users of a World-
# Wide Web browser may submit comments to the webmasters
# (or anyone else) at a site. It should be compatible with
# any CGI-compatible HTTP server.
#
# Please read the README file that came with this distribution
# for further details.
# ------------------------------------------------------------
# ------------------------------------------------------------
# This package is Copyright 1994 by The Tech.
# Form-mail is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.
# Form-mail is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Form-mail; see the file COPYING. If not, write to the Free
# Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# ------------------------------------------------------------
# Define fairly-constants
# This should match the mail program on your system.
$mailprog = '/usr/lib/sendmail -t';
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Stop people from using subshells to execute commands
# Not a big deal when using sendmail, but very important
# when using UCB mail (aka mailx).
# $value =~ s/~!/ ~!/g;
# Uncomment for debugging purposes
# print "Setting $name to $value<P>";
$FORM{$name} = $value;
}
# This should be set to the username or alias that runs your
# [URL unfurl="true"]WWW server.[/URL]
$recipient = $FORM{'email'};
# Now send mail to Pertmaster
open (MAIL, "|$mailprog") || die "Can't open $mailprog!\n";
print MAIL "From: $FORM{'email'} \n";
print MAIL "To: downloadmca\@pertmaster.com \n";
print MAIL "Subject: $FORM{'company'}-$FORM{'name'}, [URL unfurl="true"]WWW download[/URL] \n\n";
print MAIL "name = $FORM{'name'}\n";
print MAIL "company = $FORM{'company'}\n";
print MAIL "email = $FORM{'email'}\n";
print MAIL "country = $FORM{'country'}\n";
print MAIL "tel = $FORM{'tel'}\n";
print MAIL "\n------------------------------------------------------------\n";
print MAIL "Server protocol: $ENV{'SERVER_PROTOCOL'}\n";
#print MAIL "Remote host: $ENV{'REMOTE_HOST'}\n";
print MAIL "Remote IP address: $ENV{'REMOTE_ADDR'}\n";
close (MAIL);
# Now send mail to user
use MIME::Lite;
use Net::SMTP;
my $from_address = 'sales@pertmaster.com';
my $to_address = $recipient;
my $subject = "Welcome to MonteCarlo Analyzer!";
my $mime_type = "text/html";
# This $message_body has HTML formatting in it:
my $message_body = "<htmL>";
$message_body = $message_body."<link href='[URL unfurl="true"]http://www.pertmaster.com/inc/layoutStyles.css'[/URL] rel='stylesheet' type='text/css'>";
$message_body = $message_body."<link href='[URL unfurl="true"]http://www.pertmaster.com/inc/contentStyles.css'[/URL] rel='stylesheet' type='text/css'>";
$message_body = $message_body."<body><table width='635' height='100%' border='0' cellpadding='0' cellspacing='0'>";
$message_body = $message_body."<tr><td valign='top' class='copyColumnCopy' width='490'> ";
$message_body = $message_body."<table width='96%' border='0' cellspacing='0' cellpadding='4'>";
$message_body = $message_body."<tr><td valign='top'>";
$message_body = $message_body."<div class='homeBox' style='height:155px;'><table width='487' ><tr><td width='47'> <br>";
$message_body = $message_body."<div align='left'><a href='[URL unfurl="true"]http://www.pertmaster.com'><img[/URL] src='[URL unfurl="true"]http://www.pertmaster.com/images/Small_Logo.jpg'[/URL] border='0'alt='Pertmaster Logo' ></a></div></td>";
$message_body = $message_body."<td width='496'> <div align='center'><b><font face='Arial Narrow' size='5pt'>MonteCarlo Analyzer Evaluation</font></b><br> ";
$message_body = $message_body."<font face='Arial Narrow' size='4pt' color='#9B052A'><b>Download Confirmation </b></font></div></td></tr></table>";
$message_body = $message_body."<table width='485' border='0' class='mainCopy' ><tr><td><br>Dear <b>$FORM{'name'}</b>,";
$message_body = $message_body."<p>Thanks for your interest in MonteCarlo Analyzer software and we hope that you will have a successful evaluation.</p>";
$message_body = $message_body."<p>The licence number required for this evaluation is <b>4400-1015-8492-0021-9348</b>.</p>";
$message_body = $message_body."<p>To get started quickly try running through the Tutorial under the Help menu. Our Tutorial provides you with a step by step guide to running MCA as a powerful risk add-on to Primavera.</p>";
$message_body = $message_body."<p>Kind regards.<br><br>Pertmaster Software Team</p>";
#UK address
$message_body = $message_body."<table width='100%' border='0'><tr><td><p><b><font size='1'>In the UK:</font></b><font size='1'><br>";
$message_body = $message_body."Pertmaster Ltd<br>The Surrey Technology Centre<br>40 Occam Road<br>Guildford, Surrey<br>GU2 7YG<br>United Kingdom<br><br>";
$message_body = $message_body."tel: +44 (0)1483 685 190<br>fax: +44 (0)1483 573 704<br>email: <a href='mailto:info@pertmaster.com?subject=MCA Query'>info\@pertmaster.com</a></font></p>";
#US address
$message_body = $message_body."</td><td><b><font size='1'>In the US:</font></b><font size='1'><br>";
$message_body = $message_body."Pertmaster Llc<br>2100 West Loop South<br>Suite 900<br>Houston<br>TX 77027<br>USA<br><br>";
$message_body = $message_body."tel: +1 713 595 7656<br>fax: +1 713 595 7657<br>";
$message_body = $message_body."email: <a href='mailto:info\@pertmaster.com?subject=Monte Carlo Analyzer Query'>info@pertmaster.com</a></font></td></tr></table>";
$message_body = $message_body."<p>***********************************************************<br>";
$message_body = $message_body."This e-mail and any attachments are confidential and may also be ";
$message_body = $message_body."privileged.<br> If you are not the named recipient, please notify the ";
$message_body = $message_body."sender immediately<br> and do not disclose the contents to another person,";
$message_body = $message_body."use it for any purpose,<br> or store or copy the information in any medium.";
$message_body = $message_body."Any views or opinions<br> presented are solely those of the author and do ";
$message_body = $message_body."not necessarily represent<br> those of Pertmaster. Pertmaster is unable to ";
$message_body = $message_body."guarantee the security<br> (especially that of attached files) of any email content outside of our own<br> computer systems.";
$message_body = $message_body."<br>***********************************************************</p></td></tr></table></div></td></tr></table></td>";
$message_body = $message_body."<td valign='top' width='145'><br><div><img src='[URL unfurl="true"]http://www.pertmaster.com/mcanalyzer/images/MCApricing4_4.gif'[/URL] border='0'></a></div><br>";
#$message_body = $message_body."<div><a href='[URL unfurl="true"]http://www.mcanalyzer.com/'><img[/URL] src='[URL unfurl="true"]http://www.pertmaster.com/images/subscribe_email/MCAlink.gif'[/URL] border='0'></a></div>";
#$message_body = $message_body."<div><a href='[URL unfurl="true"]http://www.pertmaster.com/events/training'><img[/URL] src='[URL unfurl="true"]http://www.pertmaster.com/images/subscribe_email/PertmasterTraining.gif'[/URL] border='0' alt='Pertmaster Training Courses'></a></div>";
#$message_body = $message_body."<br><div><a href='[URL unfurl="true"]http://www.primavera.com/solutions/knowledge_center.html'><img[/URL] src='[URL unfurl="true"]http://www.pertmaster.com/images/subscribe_email/PrimaveraWebinar.gif'[/URL] border='0' alt='Primavera Webinar'></a></div>";
$message_body = $message_body."</td></tr></table></body></html>";
# Create the initial text of the message
my $mime_msg = MIME::Lite->new(
From => $from_address,
To => $to_address,
Subject => $subject,
Type => $mime_type,
Data => $message_body
)
or die "Error creating MIME body: $!\n";
$mime_msg->send( );
# Show them where to download
print "Location:[URL unfurl="true"]http://www.pertmaster.com/mcanalyzer/downloads/software_thanks.htm\n\n";[/URL]