#!/usr/bin/perl
#####################################################################
# File: posturl.pl #
# Version: 1.0.0 #
# For: Personal #
# Language: Perl 5.004_04 #
# Author: Neeraj C. Nigam #
# Date: May 12, 2003 #
# Purpose : #
# Revision History: #
#####################################################################
use strict;
#use ncn::sfunc ;
#use ncn::taps ;
use Net::SMTP;
my($par1,$par2) = (uc($ARGV[0]),$ARGV[1]) ; # Expects a slash at the end if directory
$par1 = $par1 || "AB";
$par2 = $par2 || "XXX";
my ($smtp);
my ($mailSrc)="XXX";
my ($sndr)="Bill Gates";
my ($qryStr,$datLen);
my (@aMain);
my ($nmPar,$nmValue);
my ($msgdat)="";
my ($web)=1;
if ( $par1 eq "X" ) {
$web=0;
if ( $par2 ne "" ) {
$mailSrc=$par2;
}
}
open (LOG,">>log.txt");
print LOG "New Record\n";
# Reading from Web Site Begin
if ( $web ) {
$datLen=$ENV{'CONTENT_LENGTH'};
read (STDIN, $qryStr, $datLen);
@aMain=split(/&/,$qryStr);
print "Content-Type: text/html\n\n";
foreach (@aMain){
($nmPar,$nmValue)=split(/=/,$_);
$nmValue =~ tr/+/ /;
$nmValue =~ s/%([\dA-Fa-f][\dA-Fa-f])/ pack ("C", hex($1))/eg;
print "$nmPar = $nmValue
\n";
if ($msgdat eq ""){
$msgdat=$nmPar . "=" .$nmValue. "\n" ;
} else {
$msgdat=$msgdat . $nmPar . "=" .$nmValue. "\n" ;
}
#print "$nmValue
\n";
print LOG "$nmPar = $nmValue\n";
if ($nmPar eq "fEMail") {
$mailSrc=$nmValue;
}
}
print "
\n\n";
print $msgdat;
# Read from Website End
} else {
$nmValue="Bill.Gates\@microsoft.com";
$msgdat="Email =" . $nmValue . "\n" ;
$nmValue="Bill Gates";
$msgdat=$msgdat . "Name =" . $nmValue . "\n" ;
$nmValue="Redmond, Washington";
$msgdat=$msgdat . "Add1 =" . $nmValue . "\n" ;
$nmValue="";
$msgdat=$msgdat . "Add2 =" . $nmValue . "\n" ;
$nmValue="Redmond";
$msgdat=$msgdat . "City =" . $nmValue . "\n" ;
$nmValue="WA";
$msgdat=$msgdat . "State =" . $nmValue . "\n" ;
$nmValue="00000-0000";
$msgdat=$msgdat . "Zip =" . $nmValue . "\n" ;
$nmValue="000-000-0000";
$msgdat=$msgdat . "Phone =" . $nmValue . "\n" ;
$nmValue="Mail";
$msgdat=$msgdat . "Contact by Email\n" ;
$nmValue="Your dad asked me to contact you Are you interested";
$msgdat=$msgdat . "Msg =" . $nmValue . "\n" ;
print LOG $msgdat;
}
#$smtp = Net::SMTP->new('smtpout.bellatlantic.net'); #mail host
$smtp = Net::SMTP->new('outgoing.verizon.net',Debug=>1);
#$smtp = Net::SMTP->new('outgoing.verizon.net');
if ($smtp eq ""){
print "Error connecting to Mail server\n";
print "Your message has not been sent\n";
die;
}
$smtp->auth('nnigam','password');
if ($mailSrc eq "XXX") {
$smtp->mail('nnigam@verizon.net');
} else {
$smtp->mail($mailSrc);
}
$smtp->to('pratibha@pntravels.com');
$smtp->data();
$smtp->datasend("Subject: WebFormData\n");
$smtp->datasend($msgdat);
# Try to Add Env Info
#my (@env_rep)=split(/,/,$query{'env_report'} || '');
#my ($env);
#foreach $env (@env_rep) {
# $smtp->datasend("$env: $ENV{$env}\n") or &smtperror;
#}
for (keys %ENV){
$smtp->datasend("$_: $ENV{$_}\n") or &smtperror;
}
$smtp->dataend();
$smtp->quit();
print "Your message has been sent\n";
print "