> -----Original Message----- > From: Sven Bentlage [mailto:root@;svenbentlage.de] > Sent: Thursday, November 14, 2002 2:43 PM > To: [EMAIL PROTECTED] > Subject: DBI / loop > > > Hi everyone! > > I have a small problem which should be very easy to solve, but right > now I just do not understand where the mistake is: > I`m using a small loop to fetch several hundred ids from a MySQL > database, all of the ids are pushed into @id. After that the script > fetches 1-3 email addresses for each id from another table. Directly > after fetching the address it should send an email to each id (using > only one of the max. 3 email addresses. > > The script works not completely. It fetches all ids, but > sends only 50% > of the mails... and I do not understand why.(The code is > posted below.) > > If anyone could give me a tip what to change in ma script, I would be > really grateful. > Cheers, > Sven > > @Wiggins: Thank you very much for your fast help! As soon as > I have a > working DBI Version i`ll post it. > > ################################### > > foreach $id(@id) > { > $k++; > my $dbh2 = DBI->connect( $dsn, $db_user, $db_pass ) || > die "danger > $DBI::errstr\n" ; > my $sth2 = $dbh2->prepare( "select etpa_cont_e, > cemail, pemail from > memberscopy where id='$id' " ); > $sth2->execute(); > while ( ($cont_e, $cemail, $pemail) = > $sth2->fetchrow_array) > { > > unless ($ETPA_cont_e eq "") { > $recipient = $ETPA_cont_e } > else { > if ($pemail ne "") { $recipient > = $pemail } > elsif ($cemail ne "") { > $recipient = $cemail } > elsif (($pemail eq "") and > ($cemail eq "")) {$recipient = > "root\@svenbentlage.de"} > > my $smtp = Net::SMTP->new($SMTP_Server); > die "could not connect to $SMTP_Server > using $smtp\n" unless $smtp; > > MIME::Lite->send('smtp', "SMTP_Server", ^^^^^^^^^^^^^ This looks suspicious. Perhaps that should be $SMTP_Server? Also, why are you creating a Net::SMTP object that never gets used?
> Timeout=>90); > > > my $msg = MIME::Lite->new( > #To => $recipient, > To =>'[EMAIL PROTECTED]', > #change to recipient > From =>'$sender, > ReplyTo => $reply_to, > Subject => $subject, > Type =>'multipart/related', > Encoding => '8bit' > ); > > $msg->attach(Type => 'text/html', > Data => qq{ $mailtext } > ); > $msg->send(); > > $smtp->dataend(); > $smtp->quit(); > if ($k == 828) {die();} > } > $sth2->finish(); > $dbh2->disconnect(); > > } > &thx(); > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]