No email ever arrives however, not even a bounce. I looked at the Exim logs on mysmtp.server.com, and it gives the following error:$address='one@example.com, two@example.com'; use Mail::Mailer; $msg = Mail::Mailer-> new('smtp', Server=>'mysmtp.server.com'); $msg->open({ From => 'sender@example.com', To => "$address", Subject => 'Subject', }); print $msg 'Body text here'; $msg->close();
It's probably a daft error somewhere, but I'm very new to Perl and can't see the problem from the documentation I've read. I tried two approaches with MIME::Lite. The first works perfectly if I sepecify the "To" line as follows:2003-09-19 10:28:30 SMTP call from (clientname)(localhost.localdomain) + [IP address] dropped: too many unrecognized commands
but if I use:To => 'one@example.com, two@example.com',
It will only send to the first address in the list. This also happens if I swap the entries for "To" & "Cc" round. The second approach was to to use a loop to send the mail as follows:$address='one@example.com, two@example.com'; my $msg = MIME::Lite-> new( From => 'sender@example.com', To => "$address", Cc => 'three@example.com', Subject => 'Subject', Type => 'text/plain', Data => 'Body text here' ); $msg-> send('smtp', "mysmtp.server.com", Timeout=>60);
This only sends mail to the first recipient as well. It goes through the loop the requisite number of times. I put a "print" statement in there to make sure. I'm sorry this is such a long question. Hopefully there is an easy solution. I've only used Perl for a week, so I've probably missed something obvious. All help very gratefully received! Thanks, Andy.use Mime::Lite; use Text::ParseWords; # $address is actually taken from a combo box on a web page # but equals the definition below. # That's why I have done the array like this. $address='one@example.com, two@example.com, three@example.com'; @addresses = parse_csv($address); while(@addresses) { my $msg = MIME::Lite-> new( From => 'sender@example.com', To => shift(@addresses), Subject => 'Subject', Type => 'text/plain', Data => 'Body text here.' ); $msg-> send('smtp', "mysmtp.server.com", Timeout=>60); } .... sub parse_csv { return quotewords("," => 0, $_[0]); }
In reply to Mail::Mailer & MIME:Lite On Win2k by Murf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |