Hello :

I am once again, working an automated MLM script for my client. My program incorporates Mail::Bulkmail, DBI and MIME::Lite.

 

Here is the code:

 

#!/usr/bin/perl -w ## Test Email Subroutine: use strict; use DBI; use Mail::Bulkmail; use MIME::Lite; use Net::SMTP; my($email_name, $body_text, @corpus); ## Components my $sender = "checkitout\@ogundevelopment.com"; #Step 1: Give Subject line and Open Body of Email: print"\n Please indicate the file that contains the body of your email +:\t\t"; print"\n"; $body_text = <STDIN>; #Open Email File and load into array @corpus. open(MYFILE, $body_text) || die "Cannot Open File $body_text.\n"; @corpus = <MYFILE>; close(MYFILE); mailfunc($sender,@corpus); exit(0); #### Subroutine for sending email message: sub mailfunc { my($from, @body) = @_; my $relay = "gorillatrades.com"; ## Mail Server. my $smtp = Net::SMTP->new($relay); ## Mail Object Handler. die "Could not commicate with $relay. $!" if (!defined $smtp); my @images; ## Stores Images references; my $message = join(' ', @body),"\n"; # Create the initial text of the message my $mime_msg = MIME::Lite->new( Type => "multipart/mixed", ) or die "Error creating MIME body: $!\n"; $mime_msg-> attach(Type => 'text/html', Data => "$message" ); my $message_body = $mime_msg-> body_as_string(); #### Send out Email. my $bulk = Mail::Bulkmail->new( From => $from, Smtp =>$relay, Subject => 'This is a test message!', Message => $message_body ); #Database my $dbh = DBI -> connect("DBI:mysql:database=$datab +ase , $user, $pass, {PrintError => 0, RaiseError => 1}); my $sth = $dbh->prepare("SELECT email FROM beta"); $sth->execute; $bulk->LIST(\&{$sth->fetchrow_array()}); ## Second Send Message Using ONLY MIME #MIME::Lite->send('smtp', "ogundevelopment.com", Timeout=>60); #$mime_msg-> send(); $bulk->bulkmail; $dbh->disconnect; }

The error I get is this:

 

DBI::db=HASH(0x848a9c4)->disconnect invalidates 1 active statement handle (either destroy statement handles or call finish on them before disconnecting) at t1.pl line 88.

 

Please help.

 

Peace --

Cappa

PS: I would like to thank all of the Perl Monks for their previous assistance YOU GUYS ROCK!!!


In reply to DBI Driven MLM by Cappadonna3030

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.