in reply to Re: sending to multiple recipients with Net::SMTP
in thread sending to multiple recipients with Net::SMTP

You can do $smtp->to(...) multiple times. This is how we have it set up:

@email=qw(address1@host1.com address2@host2.com address3@host3.com); $smtp->new('my.mailhost'); $smtp->mail('myaddress@myhost.com'); foreach (<@email>) { $smtp->to($_); } $smtp->datasend("Rule 42 is now in effect.\n"); $smtp->dataend; $smtp->quit;
Perhaps not the cleanest, but it works quite nicely.

Update: forgot the $smtp->quit;. Also removed commas from @email=qw(...) per comment below.

Replies are listed 'Best First'.
Re^3: sending to multiple recipients with Net::SMTP
by muntfish (Chaplain) on Nov 08, 2004 at 13:52 UTC

    Thanks for confirming that.

    Just for the sake of pedantry, you have commas in your qw() which shouldn't be there. Perl will warn you about this if you have warnings turned on.


    s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&
      Thanks, I couldn't remember if the commas would have been in there or not, I don't normally set array's like that.