我正在尝试向群组发送电子邮件但无法发送 catch是我的脚本是发送电子邮件到个人ID,但不是组。
用Google搜索但没有多大帮助。
对于发送给批量用户,我不想使用别名,但有一些限制。
请建议
#!/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
答案 0 :(得分: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";