#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use Net::SMTP::SSL;
my %conf = (
smtp => 'smtp.gmail.com',
from => 'lightaisme at gmail.com',
pwd => 'cmjmozyxukeikcme',
intr => 0.2,
);
my %opt;
GetOptions(\%opt, "body=s", "list=s") or die "Options: --body <file> --list <CSV adress>\n";
die "Please enter options \n" unless($opt{body} && $opt{list} );
open BODY,$opt{body} or die "can't read body $!\n";
my $body = join "", <BODY>;
close BODY;
print "Body = \n ".$body." \n End Body \n";
open LIST, $opt{list} or die "Can't read list: $!\n";
while(<LIST>) {
chomp;
my $adr = $_;
# print "Cur adressse = $adr \n";
my $smtp;
if (not $smtp = Net::SMTP::SSL->new($conf{smtp},
Port => 465,
Debug => 1)) {
die "Could not connect to server\n";
}
$smtp->auth($conf{from}, $conf{pwd})
|| die "Authentication failed!\n";
$smtp->mail($conf{from})
or die "Error: MAIL FROM\n";
$smtp->to($adr)
or die "Error: RCPT TO\n";
$smtp->data()
or die "Error: DATA\n";
$smtp->datasend($body)
or die "Can't send message\n";
$smtp->dataend()
or die "Error (DATA end)\n";
$smtp->quit()
or die "Error: QUIT\n";
sleep $conf{intr};
}
close LIST;
print "Mailing finish \n";