not able to send bulkmail through sendmail

216 views Asked by At

I am trying to send e-mail to a group but not being able to send catch is my script is sending e-mail to individual id, but not group.

Googled it but not much helpful.

For sending to bulk users i don't want to use alias, some restrictions.

Please Advice

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

$to = '[email protected],';
$from = '[email protected]';
$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
1

There are 1 answers

0
AnFi On

Pass list of recipients as sendmail command line arguments - AFAIR it should work on Linuxes for a few hundredth recipients.

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

my @to = ('[email protected]','[email protected]');
my $from = '[email protected]';
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";