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:
是否可以使用Mail :: Sender发送仅包含cc或密件抄送收件人的电子邮件?当我尝试发送没有“到”地址的电子邮件时,我得到了预期的返回码:
-8 = argument $to empty
-8 =参数$为空
3 个解决方案
#1
Using an empty string ''
in the "to" field does not work. Using a space works like a charm.
在“to”字段中使用空字符串''不起作用。使用空间就像魅力一样。
use Mail::Sender;
my $sender = Mail::Sender->new();
my $mail = {
smtp => 'mailserver',
from => 'example@example.com',
to => ' ',
bcc => 'example@example.com',
subject => 'test',
ctype => 'text/plain; charset=utf-8',
skip_bad_recipients => 1,
msg => 'test'
};
my $ret = $sender->MailMsg($mail);
print $ret;
#2
Does the fake_to
parameter work:
fake_to参数是否有效:
fake_to
=> the recipient's address that will be shown in headers. If not specified we use the value of "to".
=>将在标题中显示的收件人地址。如果未指定,我们使用“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.
如果您要将邮件发送到的地址列表很长,或者如果您不希望收件人看到彼此的地址,请将fake_to参数设置为一些信息,但虚假,地址或邮件/通讯组列表的地址。
http://metacpan.org/pod/Mail::Sender
Looking at the source, it seems you'd still need to set the to
parameter to something. Perhaps " "
would do the trick?
看一下这个来源,你似乎仍然需要将to参数设置为某个东西。也许“”会成功吗?
#3
Have you tried using '' ?
你试过用''吗?
#1
Using an empty string ''
in the "to" field does not work. Using a space works like a charm.
在“to”字段中使用空字符串''不起作用。使用空间就像魅力一样。
use Mail::Sender;
my $sender = Mail::Sender->new();
my $mail = {
smtp => 'mailserver',
from => 'example@example.com',
to => ' ',
bcc => 'example@example.com',
subject => 'test',
ctype => 'text/plain; charset=utf-8',
skip_bad_recipients => 1,
msg => 'test'
};
my $ret = $sender->MailMsg($mail);
print $ret;
#2
Does the fake_to
parameter work:
fake_to参数是否有效:
fake_to
=> the recipient's address that will be shown in headers. If not specified we use the value of "to".
=>将在标题中显示的收件人地址。如果未指定,我们使用“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.
如果您要将邮件发送到的地址列表很长,或者如果您不希望收件人看到彼此的地址,请将fake_to参数设置为一些信息,但虚假,地址或邮件/通讯组列表的地址。
http://metacpan.org/pod/Mail::Sender
Looking at the source, it seems you'd still need to set the to
parameter to something. Perhaps " "
would do the trick?
看一下这个来源,你似乎仍然需要将to参数设置为某个东西。也许“”会成功吗?
#3
Have you tried using '' ?
你试过用''吗?