Cappadonna3030 has asked for the wisdom of the Perl Monks concerning the following question:
I am creating an automated Mail Manager called automailer.pl that use MySQL and perl modules. I am using MIME:: Lite, Net::SMTP and of course, DBI. The script will run fine for about 40 or 50 emails, but eventually, I will get this crazy error and hte script will fail:
Exception caught: Failed to connect to mail server: Bad file descriptor at automailer.pl line 219
Could not commicate with "mailserver". Connection refused at automailer.pl line 182, <STDIN> line 3.
The code that sends the emails is here:
#### Subroutine for sending email message: #### Subroutine for sending email message: sub mailfunc { my($to, $from, $subject, @body) = @_; use MIME::Lite; use Net::SMTP; 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( From => $from, To => $to, Subject => $subject, Type => "multipart/mixed", ) or die "Error creating MIME body: $!\n"; ##Find all image references ##Converting MIME type into String: #print "$message"; #HTML $mime_msg-> attach(Type => 'text/html', Data => "$message"); my $message_body = $mime_msg-> body_as_string(); #### Send out Email. ## Second Send Message Using ONLY MIME MIME::Lite->send('smtp', $mailserver, Timeout=>60); eval { $mime_msg-> send(); }; $@ and warn "Exception caught: $@\n\n"; print "Sent Normally to $to.\n\n"; $@ and warn "Exception caught: $@\n\n"; }
Janitored by holli - added code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MIME Lite Module constantly crashing
by zentara (Cardinal) on Jun 14, 2005 at 12:34 UTC | |
by Cappadonna3030 (Sexton) on Jun 15, 2005 at 01:10 UTC | |
|
Re: MIME Lite Module constantly crashing
by fireartist (Chaplain) on Jun 14, 2005 at 12:13 UTC | |
by Cappadonna3030 (Sexton) on Jun 16, 2005 at 01:40 UTC | |
by fireartist (Chaplain) on Jun 16, 2005 at 08:04 UTC | |
|
Re: MIME Lite Module constantly crashing
by cowboy (Friar) on Jun 14, 2005 at 15:04 UTC | |
by Ultra (Hermit) on Jun 17, 2005 at 15:57 UTC | |
|
Re: MIME Lite Module constantly crashing
by Ultra (Hermit) on Jun 14, 2005 at 13:55 UTC |