Hi Ryan!
(My MTA is playing with me, so if you are receiving this for the second
time I'm deeply sorry!)
Do yourself a big favor and use warnings and strict:
#!/usr/bin/perl -w
use strict;
If you had done that you would immediately have spotted the problem,
which was a missing dollar sign for the rcpts element in the line:
> $email->recipient(@{ rcpts{$server} });
Should be:
$email->recipient(@{ $rcpts{$server} });
I believe this is just a typing error. Good luck!
Gretar M. Hreggvidsson
[EMAIL PROTECTED]
Ryan Frantz wrote:
> 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;
>
> }
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>