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

pitbull3000 has asked for the wisdom of the Perl Monks concerning the following question:

im trying to write a newsletter script, and now i got the question,how can i send the email to all the recipients without connecting to smtp for every recipient. i.e. sending the mail once to my smtp server with an array of to adresses... is this possible and how? thanks all you wise men oliver

Replies are listed 'Best First'.
Re: sending the same email more than once without connecting to smtp for every To adress
by rchiav (Deacon) on Aug 25, 2001 at 03:18 UTC
    Actually, you can do it just as you described. Just pass an array to the "to" method...
    my $smtp = Net::SMTP->new($srv); $smtp->mail('root@localhost'); $smtp->to(@emails); $smtp->data(); $smtp->datasend("Your data goes here.\n"); ....
    Hope this helps..
    Rich
      ok cool i was on the right way, is there also the possibility to send attachments with net::smtp, i already read the docs but didnt find anything. is it like sendmail that i specify the header with "content type multipart/mixed...... boundary...." if yes, how is the syntax... ;.))
        For that, you're going to want to use MIME::Lite..

        All the info you're looking for is at that link.

        Hope this helps..
        Rich

Re: sending the same email more than once without connecting to smtp for every To adress
by dondelelcaro (Monk) on Aug 25, 2001 at 03:13 UTC
    Checkout Mail::Bulkmail which will help you out to do this.

    Update: I need to keep up with the previous posts on this subject. Rich's method is the way to go if you're already using Net::SMTP for smaller numbers of e-mail recipients.
      unfortunately mail::bulkmail isnt installed on the server of my isp, so i think i tr the solution with passing an arry to smtp
Re: sending the same email more than once without connecting to smtp for every To adress
by Trimbach (Curate) on Aug 25, 2001 at 06:18 UTC
    Sending your newsletter to everyone at once on a bcc: line instead of a to: line is also a possibility. One connection, one email, no fuss.

    Gary Blackburn
    Trained Killer