I havn't tested it, and you havn't showed your code, but you should be able to authenticate once before sending, the do a bunch of sends in a loop. See Autentication problem with MIME::Lite for some code. Just don't send the $smtp->quit until all are sent. Google for "Net::SMTP bulkmail", for some code examples.
Beware your ISP may have limits set on your account to prevent spammers, and you may be violating your terms of agreement if you send too many mails. Better be safe, and ask your ISP's tech support for your limits.
| [reply] |
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] |
If it's the same email, is there any reason you can't just put them all in the 'to' (or better yet, the 'BCC') field?
That would let your web host send it more efficiently: Only one copy is sent over the network to a specific domain, if multiple recipients are in the domain. And it reduces the number of times you need to connect to them.
| [reply] |
I am a newbie. My apologies, if I am stating something very dumb.
I run a web portal with about 20,000 subscribers. I need to send them a newsletter twice a month. I have done the following:
I have added SPF record/DomainKeys for my domain.
I do need to use SMTP authentication so that I can handle bounces properly. Mail::Bulkmail would have been a good choice, but I could not figure out if it supports SMTP authentication
What I see here works for me. I just have couple of question
- Can I use Bulkmail instead, if it supports SMTP authentication
- Would it work, if I group addresses by domain and stuff into the To field and then do as many sends as there are domains. There could be thousands addresses for each domain
- If not, instead of doing a new in the loop, can I do the new outside the loop and replace the 'To' field within the loop. Any performance gain there?
| [reply] |