0

我正在尝试向一个群组发送电子邮件,但无法发送 catch 是我的脚本正在向个人 ID 发送电子邮件,而不是群组。

谷歌搜索但没有多大帮助。

对于发送给批量用户,我不想使用别名,有一些限制。

请指教

#!/usr/bin/perl
#!/usr/sbin/sendmail

$to = 'xxxx@yyy.something.com,';
$from = 'abc@something.com';
$subject = 'Subject';
#$message = 'This is test mail';



open(MAIL, "|/usr/sbin/sendmail -t");

# Email Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
# Email Body
print MAIL "print something";

close(MAIL);
#print "Email Sent Successfully\n
4

1 回答 1

0

将收件人列表作为 sendmail 命令行参数传递 - AFAIR 它应该在 Linux 上为几百个收件人工作。

#!/usr/bin/perl
use strict;
use warnings;

my @to = ('xxxx@yyy.something.com','yyyy@xxx.something.com');
my $from = 'abc@something.com';
my $subject = 'Subject';

#my $child_pid = open(MAIL, "|-")   // die "can't fork: $!";
defined( my $child_pid = open(MAIL, "|-")) || die "can't fork: $!";
if( $child_pid == 0 ) {
   exec( '/usr/sbin/sendmail', '-i', '--', @to) || die "can't exec: $!";
}

# Email Headers & Body
print MAIL << "END" ;
From: $from
Subject: $subject

print something
END
close(MAIL) && print "Email Sent Successfully\n";
于 2014-07-17T08:48:25.570 回答