http://qs321.pair.com?node_id=635482


in reply to Re: Just can sent only ONE mail every time.
in thread Just can sent only ONE mail every time.

Thanks. But if i put the new Net::SMTP in sub sendMail.It means every list will be connect the mail server once,it's so time-consuming.
Do you some other method.Or how to organise the "order" ?Thanks again
  • Comment on Re^2: Just can sent only ONE mail every time.

Replies are listed 'Best First'.
Re^3: Just can sent only ONE mail every time.
by ikegami (Patriarch) on Aug 28, 2007 at 03:33 UTC
    Did you check if SMTP (or the version on which Net::SMTP is based) can send more than one message per connection? Even HTTP wasn't able to do so originally. At a glance, it doesn't look like SMTP can either.
      Fixed! Thanks everybody.
      I only add a sub "over" and comment the sub "quit" in sendMail :
      sub over { $self = @_; $self->{SMTP}->quit;

      Then i add the sub in end of my a.pl

      ... use MySMTP; $mail = new MySMTP(); my @lists = $mail->get_list(); for my $addr (@list) { $mail->sendMail($addr,"how are you"); } $mail->over(); ## Add here
        As an afterthought, since you already fixed it. Here's a peice of advice that may or may not work for you. I am currently working with SMTP for work with a postfix mta system. you may want to consider using threads and Thread::Queue. then you queue up your messages, create a pre-defined number of threads and just have them pull from the queue then join when they are done. Very fast very efficient.

        "One future, two choices. Oppose them or let them destroy us" - Propaghandi
Re^3: Just can sent only ONE mail every time.
by GrandFather (Saint) on Aug 28, 2007 at 03:32 UTC

    Why not simply pass the list of addresses in and send the one email to multiple recipients using either TO or BCC addressing?


    DWIM is Perl's answer to Gödel