tags:

views:

254

answers:

3

Is it possible to send an Email with only cc or bcc recipients using Mail::Sender? When I try to send an Email without a "to" address, I get the expected return code:

-8 = argument $to empty

A: 

Have you tried using '' ?

TheTXI
Yes, it still results in the -8 error code.
cowgod
+2  A: 

Does the fake_to parameter work:

fake_to

=> the recipient's address that will be shown in headers. If not specified we use the value of "to".

If the list of addresses you want to send your message to is long or if you do not want the recipients to see each other's address set the fake_to parameter to some informative, yet bogus, address or to the address of your mailing/distribution list.

http://search.cpan.org/~jenda/Mail-Sender-0.8.16/Sender.pm

Looking at the source, it seems you'd still need to set the to parameter to something. Perhaps " " would do the trick?

Jon Ericson
+4  A: 

Using an empty string '' in the "to" field does not work. Using a space works like a charm.

use Mail::Sender;

my $sender = Mail::Sender->new();
my $mail   = {
    smtp                 => 'mailserver',
    from                 => '[email protected]',
    to                   => ' ',
    bcc                  => '[email protected]',
    subject              => 'test',
    ctype                => 'text/plain; charset=utf-8',
    skip_bad_recipients  => 1,
    msg                  => 'test'
};

my $ret =  $sender->MailMsg($mail);

print $ret;
cowgod