X-Git-Url: http://git.home-dn.net/?p=manu%2Fsmtpt.git;a=blobdiff_plain;f=smtpt;h=40932f1b48e2132a2f1e8aaf4cf4183f8616fb0d;hp=17814987d02a9bddb9ca8eab6e960426d72c5ffa;hb=HEAD;hpb=7fb4d67b870fea0bd11fdca762f60105e8bd6d75 diff --git a/smtpt b/smtpt index 1781498..40932f1 100755 --- a/smtpt +++ b/smtpt @@ -4,7 +4,7 @@ # # Require perl modules: Net::SMTP, AppConfig # -# Copyright (C) 2006 Emmanuel Lacour +# Copyright (C) 2006-2010 Emmanuel Lacour # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -27,7 +27,7 @@ use Net::SMTP; use AppConfig qw(:expand :argcount); my $NAME = 'smtpt'; -my $VERSION = '0.1'; +my $VERSION = '0.2'; my $AUTHOR = 'Emmanuel Lacour, '; my %count; @@ -40,7 +40,7 @@ my %sample; # Spam sample email $sample{spam} = 'Subject: Test spam mail (GTUBE) From: Sender <{FROM}> -To: Recipient <{TO}> +To: {TO} MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit @@ -65,7 +65,7 @@ You should send this test mail from an account outside of your network. # Nospam/novirus sample email $sample{normal} = 'Subject: Test mail nospam/novirus From: Sender <{FROM}> -To: Recipient <{TO}> +To: {TO} MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit @@ -76,7 +76,7 @@ Essai nospam/novirus # Virus sample email $sample{virus} = 'From: Sender <{FROM}> -To: Recipient <{TO}> +To: {TO} Subject: Test virus Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="C7zPtVaVf+AK4Oqc" @@ -125,7 +125,8 @@ sub usage { ARGUMENTS: --host=HOST the host to connect to --from=FROM the sender email - --to=TO the recipient email + --to=TO the recipient email (use it multiple time for more than + one recipient) --spam=SPAM_COUNT the number of spam emails to sent --virus=VIRUS_COUNT the number of virus emails to sent --normal=NORMAL_COUNT the number of nonspam/nonvirus emails to sent @@ -149,7 +150,7 @@ sub main { my $appconfig = AppConfig->new( 'host=s', 'from=s', - 'to=s', + 'to=s@', 'spam=s', 'virus=s', 'normal=s', @@ -171,7 +172,8 @@ sub main { my $host = $opt{host}; my $from = $opt{from}; - my $to = $opt{to}; + my @to = @{$opt{to}}; + my $to_formatted = join(", ", @to); $count{spam} = $opt{spam}; $count{virus} = $opt{virus}; $count{normal} = $opt{normal}; @@ -202,13 +204,13 @@ sub main { foreach my $type (keys%count) { my $i = 0; while ($i < $count{$type}) { - print "Sending: $from -> $to, $type\n"; + print "Sending $type: $from -> $to_formatted\n"; $smtp->mail($from) or error("From failed: $!\n"); - $smtp->to($to) or error("To failed: $!\n"); + $smtp->to(@to) or error("To failed: $!\n"); $smtp->data() or error("Data failed: $!\n"); my $sent_size = 0; my $body = $sample{$type}; - $body =~ s/{TO}/$to/g; + $body =~ s/{TO}/$to_formatted/g; $body =~ s/{FROM}/$from/g; # Disable special virus mangling (needed for letting people using an http AV download this toool ;)) $body =~ s/{DEACTIVATED}//g; @@ -258,7 +260,7 @@ The sender email. =head2 B<--to>=I -The recipient email. +The recipient email. (use it multiple time to specify more than one recipient) =head2 B<--spam>=I