I have problem in sending bulk mails using perl. email id's are being read from the database which is MySQL.
I'm able to read the email id's from the database and I'm getting the confirmation message stating that the mail has been sent, but actually the mail is not going. But if I send email to only one email Id the mail is going. Please let me know what might be the problem.
thanks in advance
Ashok
Here is the code
----------------------
#! /usr/bin/perl
print "Content-type: text/html \n\n";
require "../../quickpro/config.pl"
;
require "../../quickpro/sconfig.pl
";
require "globals.pl";
require "variables.pl";
use CGI::Carp qw/fatalsToBrowser/;
use CGI qw (:standard);
$form=new CGI;
@variables=$form->param;
foreach $variables(@variables){${$
variables}
=$form->pa
ram($varia
bles);}
&connect_sql;
$SQL="SELECT * from recipientstemp";
&my_sql;
$i=1;
while($column=$sth->fetchr
ow_hashref
)
{
$id=$column->{'ID'};
$firstname=$column->{'firs
tname'};
$lastname=$column->{'lastn
ame'};
$email=$column->{'email'};
$phone=$column->{'phone'};
$url=$column->{'url'};
$company=$column->{'compan
y'};
$ipaddr=$column->{'ipaddre
ss'};
$confirmlink="$DomainURL/c
gi-bin/qui
ckpro/succ
ess.cgi?id
=$id";
&personalize;
#print "$id,$firstname,$email,$ip
addr";
$email=~s/@/\@/g;
$from=~s/@/\@/g;
if($i==1)
{
$temp=$email;
$i++;
}
else
{
$temp=$temp.",".$email;
print $temp;
}
}
unless(open (MAIL, "|/usr/sbin/sendmail -t"))
{
print "error.\n";
}
else
{
#open (MAIL, "|$sendmail -t") || die "I can't open sendmail\n";
print MAIL "To: $firstname <$temp>\n";
print MAIL "From:$from\n";
print MAIL "Subject:$subject\n";
print MAIL "Mime-Version:1.0\n";
print MAIL "Content-Type:text/plain\;
charset=\"US-ASCII\"\n";
print MAIL "Content-Transfer-Encoding
: 7bit\n";
print MAIL $message;
close(MAIL);
print "Mail sent";
}
$sth->finish;
$dbh->disconnect;
#print "<a href=$DomainURL/cgi-bin/qu
ickpaypro/
success.cg
i?id=$id>"
;
print qq|
<html>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="$darkcolor" background="$DomainURL/ima
ges/$mybac
kground">
<tr>
<td><img height="60" width="360" src="$DomainURL/images/$my
logo"></td
>
</tr>
</table>
<center>
<br><br>
<b>Confirmation mail has been sent</b>
</body>
</html>
|;
Start Free Trial