Perlers,

 

I need to send an email to several different recipients, all at
different mail servers.  I thought that a hash of arrays (my first time)
would do the job nicely, but Net::SMTP complains that I can't "coerce
array into hash".

 

Here's my script (Win32):

 

# hash the recipients -> a hash of arrays!!  woohoo!

my %rcpts = (

  'mail.domain0.com' => [ '[EMAIL PROTECTED]', '[EMAIL PROTECTED]' ],

  'mail.domain1.com' => [ '[EMAIL PROTECTED]' ],

  'mail.domain2.com' => [ '[EMAIL PROTECTED]' ]

);

 

my $send_from = '[EMAIL PROTECTED]';

my $send_to = "Interested Parties"

my $subj = "Something happened...";

my $msg = "...and it's going to cost us...";

 

# test the HoA...

foreach my $server ( keys %rcpts ) {

  #print "$server: @{ $rcpts{$server} } \n";

 

  #my $email = Net::SMTP->new($server, Hello => $site, Debug => 5) or
warn "Unable to create email: $!\n";

  my $email = Net::SMTP->new($informed_smtp_host, Hello => $site) or
warn "Unable to create email: $!\n";

  $email->mail($send_from);

  $email->recipient(@{ rcpts{$server} });

  $email->data();

  $email->datasend("To: $send_to\n");

  $email->datasend("Subject: $subj\n");

  $email->datasend($msg);

  $email->dataend();

  $email->quit;

 

What gives?

 

ry

 

}

Reply via email to