PDA

View Full Version : Send mail code not sending e-mail


havingababy
02-18-2003, 09:11 AM
I have tried for weeks to get this cgi (birth announcement) script to work http://www.havingababy.net/hello_baby/index.htm I have no idea how to fix it. It makes the web page and uploads the photo but it never sends the e-mail out. The host server is unix and sendmail is not the problem. I would be very thankful for any advice.

Best Regards,

Frederic



# Start off by reading and parsing the data. Save the return value.
# Pass references to retreive the data, the filenames, and the content-type
$ret = &ReadParse(\%cgi_data,\%cgi_client,\%cgi_type,\%cgi_temp);

$index=$cgi_data{'index'};
$template=$cgi_data{'template'};
$email=$cgi_data{'email'};
$parent=$cgi_data{'parent'};
$hometown=$cgi_data{'hometown'};
$babyname=$cgi_data{'babyname'};
$birthday=$cgi_data{'birthday'};
$birthtime=$cgi_data{'birthtime'};
$sex=$cgi_data{'sex'};
$weight=$cgi_data{'weight'};
$length=$cgi_data{'length'};
$photo=$cgi_data{'photo'};
$photo_caption=&strip($cgi_data{'photo_caption'});
$details=&strip($cgi_data{'details'});
$momsaid=&strip($cgi_data{'momsaid'});
$dadsaid=&strip($cgi_data{'dadsaid'});
$friends=&strip($cgi_data{'friends'});

($begin, $end)=split(" ", $cgi_data{'babyname'}, 2);
$begin=~s/\\//g;
$begin=~s/\///g;

$babypage=$pagedir."\\baby_".$index."_".$begin.".html";
$babypage=lc($babypage);
$babylink="baby_".$index."_".$begin.".html";
$babylink=lc($babylink);

$message="

Hello!

You're invited to see a something new and exciting.
please visit the following URL:

$home/babies/$babylink

$cgi_data{'message'}\n\n
$parent
$email";


push(@recipient,split(",",$friends));
for ($x=0; $x <= $#recipient; $x++){

if ((uc($mailer) eq "BLAT" || uc($mailer) eq "GBMAIL") && $recipient[$x] ne "" ){
&go_nt;
}

elsif (uc($mailer) eq "MAIL"){
&go_unix;
}

}



open(BABYPAGE, ">$babypage");
$trigger="1";
&template_thing;
close (BABYPAGE);

print "content-type:text/html\n\n";

print "<HEAD><title>Congratulations!</title>\n";
print "</head>\n";

print "<body bgcolor=\"#ffffff\" >\n";
print "<center><TABLE width=\"520\">\n";

print "<TR><TD colspan=\"2\"><H2>Congratulations</h2></td></tr>\n";
print "<TR><TD colspan=\"2\"><P>You successfully Created a Baby Announcement. The url is: <A HREF=\"$home/babies/$babylink\">$home/babies/$babylink</a><P>Go <A HREF=\"/\">back</a>.</p></td></tr>\n";
print "</TABLE></center>\n";
print "<BR><BR><B></B>\n";

print "</BODY></HTML>\n";



exit;





sub go_nt{
open (WEASEL, "+>$weasel");
print WEASEL "$message\n";
print WEASEL "$footer\n";
close WEASEL;

push(@recipient,split(",",$FORM{'to'}));
for ($x=0; $x <= $#recipient; $x++){

if(uc($mailer) eq "BLAT"){
system("$blat $weasel -s \"SOMETHING NEW AND EXCITING!\" -t $recipient[$x]");
}
if(uc($mailer) eq "GBMAIL"){
system("$gbmail -file $weasel -h $host -from $return -to $recipient[$x] -s \"SOMETHING NEW AND EXCITING!\"");

}
}


close WEASEL;
unlink(WEASEL);



}


sub go_unix{


if (uc($mailer) eq "MAIL"){
push(@recipient,split(",",$FORM{'to'}));
for ($x=0; $x <= $#recipient; $x++){
&notify("$recipient[$x]", "SOMETHING NEW AND EXCITING!", "$message");
}
}


if (uc($mailer) eq "SENDMAIL" ){

push(@recipient,split(",",$FORM{'to'}));
for ($x=0; $x <= $#recipient; $x++){
&sendmailer("$recipient[$x]", "$from", "SOMETHING NEW AND EXCITING!", "$message");
}
}

close WEASEL;
unlink(WEASEL);

}

If nothing above is a problem than it may be in the following script:
Note: The path /usr/sbin/sendmail below is correct.

#What's the main URL for your web site?
$home="http://www.havingababy.net/hello_baby";

#What's the root file path to your web site?
$homepath="/home/havingab/public_html/hello_baby";

$pagedir="$homepath/babies/";
$counter="$homepath/babies/count.txt";
$weasel="$homepath/babies/weasel.txt";

#which mailer are you using? "Blat/gbmail" (NT) or "mail"?
#$mailer="Blat";# option for NT
#$mailer="gbmail"; # option for NT
#$mailer="mail"; #for unix
$mailer="/etc/sendmail.cw"; #for unix


#where is Blat? (For NT if selected)
#$blat="/online/cgi-shl/trial/Blat";

#where is gbmail? (ON NT)
#$gbmail="/online/cgi-shl/misc/gbmail";
#whats your smtp cost name?
#$host="localhost";
#whats the gbmail return address?
#$return="webmaster\@havingababy.net";


#where is mail? (on Unix only)
#$mail_prog = "/usr/sbin/sendmail" ;
#where is sendmail? (on Unix only)
$mail_prog="/usr/sbin/sendmail";
#what is the return address?
$from="webmaster\@havingababy.net";

:confused: