Salut
J'ai juste une question : comment faire pour envoyer un e-mail de masse sans que les recepteurs voient que c'est un mail de masse.
Merci d'avance
#!/usr/bin/perl
use strict;
use POSIX;
use DBI;
our %config;
our @groups;
$config{"aliases_file"}="/home/warbrain/Emails/mutt/aliases.rc";
$config{"lists_dir"}="/home/warbrain/Emails/Lists/";
our $dbh= DBI->connect( "dbi:SQLite:/tmp/eventspam.dbl" ) || die "Cannot connect: $DBI::errstr
";
sub create {
our $dbh;
$dbh->do("DROP TABLE emails") || print "Table is new, creating...
";
$dbh->do("DROP TABLE groups") || print "Table is new, creating...
";
$dbh->do("CREATE TABLE emails (email PRIMARY KEY,ealias UNIQUE,ename,ealone DEFAULT 1)")|| die "Cannot create table 'emails'
";
$dbh->do("CREATE TABLE groups (gname,gsub)")|| die "Cannot create table 'groups'
";
}
sub fill {
our $dbh;
our %config;
our @groups;
open(FH,$config{"aliases_file"});
my $group=0;
my $groupligne;
while(my $ligne=<FH>){
chomp($ligne);
if (($ligne =~ /^s*#/) or ($ligne =~ /^s*$/)){
## ligne vide ou commentaire
$group=0;
next;
}
$ligne=~s/^s*//;
$ligne=~s/s*$//;
$ligne=~s/s+/ /;
if ($group == 0){
my ($ealias,$ename,$email,$linetail,$groupname);
if ($ligne=~/^aliass+(S+)s*(.*?)s+<(.+?@.+?)>$/){
## ligne de mail normale
$ealias=$1;
$ename=$2;
$email=$3;
$ligne=$email;
$dbh->do("INSERT INTO emails (email, ealias, ename) VALUES ('$email','$ealias','$ename')")
or print "NOT UNIQUE: ($email,$ealias,$ename)";
#$dbh->do("INSERT INTO groups (gname,gsub) VALUES ('$ealias','$ealias')")
# or print "NOT UNIQUE: ";
#print "==> $ealias / $ename / $ligne <==
";
} elsif ( $ligne=~/^aliass+(S+).*?,.*?\$/) {
## début d'un groupe
$groupname=$1;
#print "$groupname ->
";
$group=1;
$groupligne=$ligne;
} elsif ($ligne=~/^aliass+(S+)s+(.*?)$/) {
#alias d'un alias (groupe monoligne)
$ealias=$1;
$linetail=$2;
#print "$ealias -> $linetail
";
} else {
print "INCONNU: $ligne
";
}
} else {
# group != 0
if ($ligne=~/\$/){
## la ligne se finit par ""
$ligne=~s/\$//;
$groupligne=$groupligne.$ligne;
} else {
# la ligne ne se finit pas par ""
# donc on clos le groupe
$groupligne=$groupligne.$ligne;
my $groupname=$groupligne;
$groupligne=~/^aliass+(S+)s+.*$/;
$groupname=$1;
my $res=$dbh->selectall_arrayref(q(SELECT COUNT(*) FROM groups WHERE gname='$groupname'));
if (@$res[0]->[0] == 0){
push @groups, $groupname;
#foreach my $hop ( @$res ) {
# foreach my $i (@$hop) {
# print $i." "
# }
# print "
";
#}
$groupligne=~s/^aliass+S+s+(.*)$/$1/;
$groupligne=~s/\/ /g;
$groupligne=~s/s*,s*/,/g;
my @G=split(/,/,$groupligne);
#unlink("$aliasDIR/$groupname.grp");
foreach my $gsub (@G) {
## TODO détecter les subgroup invalides
$dbh->do("INSERT INTO groups (gname,gsub) VALUES ('$groupname','$gsub')");
# print " $gsub
";
# $g=~s/^.*?s+(.*?@.*?)s+.*?$/$1/;
# $g=~s/<(.*)>/$1/;
# print "$groupname : $g
";
# system("echo '$g' >> $aliasDIR/$groupname.grp");
}
} else {
## BUG: le groupe a déja été déclaré
}
$group=0;
}
}
}
}
sub markgroups {
our @groups;
foreach my $group (@groups){
$dbh->do("UPDATE emails SET ealone=0 WHERE ealias IN (SELECT gsub FROM groups WHERE gname='$group')");
}
}
sub showalone {
our $dbh;
header("Not grouped");
my $res=$dbh->selectall_arrayref("SELECT ename,ealias,email FROM emails WHERE ealone=1");
foreach my $r ( @$res ) {
my @row=@$r;
print " - ".$row[1]." = ".$row[0]." <".$row[2].">
";
}
}
sub isfinalalias {
my ($alias)=@_;
our $dbh;
my $res=$dbh->selectall_arrayref("SELECT COUNT(*) FROM emails WHERE ealias='$alias'");
if (@$res[0]->[0] == 0){
return 0;
} else {
return 1;
}
}
sub emailgroup {
my ($groupname,$messagefile,$subject)=@_;
our $dbh;
if ((-f "$messagefile") and ($subject ne "")){
my $res=$dbh->selectall_arrayref("SELECT gsub FROM groups WHERE gname='$groupname'");
foreach my $r ( @$res ) {
my @row=@$r;
if (isfinalalias($row[0])) {
my $cmd="cat "$messagefile" | mutt '".$row[0]."' -s '$subject'
";
system($cmd);
print $cmd;
#print "F - ".$row[0]."
";
}
else {
emailgroup(($row[0],$messagefile,$subject));
}
}
} else {
print "Invalid message file
";
}
}
sub showgroups {
our @groups;
header("Current groups");
foreach my $group (@groups) {
print " - $group
";
}
}
sub header {
my ($text)=@_;
print "====================[ $text ]====================
";
}
sub usage {
print "Usage: eventspam <options>
";
print "Where options could be:
";
# print "inithome <home> Init directory "home"
";
# print "initgroup <group> Init group "home"
";
print "groups Add a new user called "login"
";
print "alone Removes user "login"
";
print "spam group message List of users in the sanctuaire
";
print "who <group> List users currently connected
";
}
create();
fill();
markgroups();
my $arg=shift;
if ($arg eq "alone"){ showalone(); }
elsif ($arg eq "groups") { showgroups(); }
elsif ($arg eq "spam") { emailgroup(@ARGV); }
else { usage(); }
$dbh->disconnect;
w0lverine a écrit::lol: Glenux, Notre Maître Geek à tous.
Ou encore: "comment pourrir sa journée du 2 janvier à envoyer ses voeux"
@Kypris: Si c'est d'un hoax (une chaîne) que tu parles, c'est très mal vu.
alias nomDeLAlias Nom Prénom <email.du@destinataire.tld>
alias nomDuGroupe aliasDePersonne1 aliasDePersonne2 aliasDePersonne3 etc...
alias nomDuGroupe aliasDePersonne1
aliasDePersonne2
aliasDePersonne3
etc...
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 6 invités
.: Nous contacter :: Flux RSS :: Données personnelles :. |