Thank you for taking the time to answer my question. I'm using MIME::LITE to send the email
MIME::Lite->send('smtp', "$host", AuthUser=>"$user", AuthPass=>"$pass");
followed by
$msg->send;
Correct me if I am wrong, but when $msg->send is called, doesn't that call the $smtp->quit command ?
If so, how can I avoid that?
| [reply] |
First you will need to show some basic code, and how you want to setup an address loop. MIME::Lite is meant for convenience not flexibility.
MIME::Lite integrates easily with Net::SMTP, as the example in the link showed. You might be better off doing a small rewrite, to use the features of Net::SMTP. All you need to do is compose your MIME::Lite message and add as as_string to the Net::SMTP object. Untested pseudo code to show the idea:
#!/usr/bin/perl
use warnings;
use strict;
use MIME::Lite;
use Net::SMTP_auth;
#login once
my $smtp = Net::SMTP_auth -> new( 'zentara.zentara.net' );
$smtp -> auth( 'LOGIN', 'z', 'ztest' );
###### put your loop here #########
foreach my $addr ( @addresses){
#compose your message as_string
#you can have a very complex MIME::Lite mail here
my $msg = MIME::Lite -> new (
From => 'z@zentara.zentara.net',
TO => $addr,
Subject => 'Testing Text Message',
Data => 'How\'s it going.' );
$smtp->mail('z@zentara.zentara.net');
$smtp->to($addr);
$smtp -> data();
$smtp -> datasend( $msg->as_string() );
$smtp -> dataend();
}
############################
## quit when finished loop
$smtp -> quit;
| [reply] [d/l] |