Skip to content

Instantly share code, notes, and snippets.

@jdiverp
Created October 25, 2024 23:12
Show Gist options
  • Select an option

  • Save jdiverp/304b209207513d9469980e992424fc4f to your computer and use it in GitHub Desktop.

Select an option

Save jdiverp/304b209207513d9469980e992424fc4f to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
## Must be set to where the bounces are to go..
my $SENDMAILBOUNCE = 'me@me.com';
print "usage: $0 <message> <recipients>\n" if($#ARGV ne '1');
exit if($#ARGV ne '1');
{
open( MSG, "<$ARGV[0]" ) or die ("message text could not be opened\n");
local( $/ ) = undef;
$msg = <MSG>;
close( MSG );
}
open( LIST, "<$ARGV[1]" ) or die ("recipients list could not be opened\n");
my $i=0;
while( <LIST> ) {
$i++;
chomp;
$tmp = $msg;
my($displayname,$email) = split (/,/,$_);
$tmp =~ s/\$\$EMAIL/$email/g;
$tmp =~ s/\$\$DISPLAYNAME/$displayname/g;
open( MAIL, "|/usr/lib/sendmail -t -f$SENDMAILBOUNCE" );
print MAIL "$tmp";
close( MAIL );
open( MAILDONE, ">>team_output" );
print MAILDONE "$tmp";
close( MAILDONE );
# print $tmp;
my $spot = $i % 100;
print "sleeping 10, position $i\n" if($spot eq 0);
sleep 10 if ($spot eq 0);
}
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment