简体   繁体   English

如何使用Mail :: Sender发送没有“收件人”地址的电子邮件?

[英]How do I send an Email with no “to” address using Mail::Sender?

Is it possible to send an Email with only cc or bcc recipients using Mail::Sender? 是否可以使用Mail :: Sender发送仅包含cc密件 抄送收件人的电子邮件? When I try to send an Email without a "to" address, I get the expected return code: 当我尝试发送没有“到”地址的电子邮件时,我得到了预期的返回码:

-8 = argument $to empty -8 =参数$为空

Using an empty string '' in the "to" field does not work. 在“to”字段中使用空字符串''不起作用。 Using a space works like a charm. 使用空间就像魅力一样。

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;

Does the fake_to parameter work: fake_to参数是否有效:

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 http://metacpan.org/pod/Mail::Sender

Looking at the source, it seems you'd still need to set the to parameter to something. 看看源代码,你似乎还需要将to参数设置为某个东西。 Perhaps " " would do the trick? 也许" "会成功吗?

你试过用''吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM