PERL NET::SMTP Cc Bcc Help Needed

Ok, I know how to use Net::SMTP to send messages with a single recipient but I am having problems using $smtp->bcc(). I want to send to multiple recipients in the bcc field. I have tried variables and arrays but nothing seems to work.

A side note: some addresses are not delivered to. i.e. the mail sent from my script is never received. Any ideas where I should start to look?

my $ServerName = $smtpserver;
$smtp = Net::SMTP->new($ServerName, Debug => 0);

$smtp->mail( $from );
$smtp->to( $to );

$smtp->datasend("To:  $to\n");
$smtp->datasend("From:  $from\n");
$smtp->datasend("Date: $mdate\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("MIME-Version: 1.0\n");
$smtp->datasend("Content-type: text/html\n");
$smtp->datasend("Content-Transfer-Encoding: 7bit\n");
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This is from a script I use for automated invoicing. It emails the client and bcc's to myself. The syntax below is from the notes I made from my programming and testing senarios. Although I only BCC myself, I would not have left the note in place if it didn't work when I tested.

   $smtp->bcc($bcc, $anotherbcc, $onemorebcc);
   # to ( ADDRESS [, ADDRESS [...]] )
   # cc ( ADDRESS [, ADDRESS [...]] )
   # bcc ( ADDRESS [, ADDRESS [...]] )

   $smtp->datasend("From: $from\n");
   $smtp->datasend("To: $to\n");
# build a subject string
   $SUBJECT="An email from us";
   $smtp->datasend("Subject: ".$SUBJECT."\n");
   $smtp->datasend("MIME-Version: 1.0\n");
   $smtp->datasend("Content-Type: text/html; charset=us-ascii\n");

   $smtp->datasend("Hope you are well.\n");
   $smtp->datasend("Have fun for the holidays\n");

   # dataend
   $smtp->dataend();    # NOT datasend!


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.