Script PERL - Sendmail with pause and time
Hi,
I have the following code e works perfectly, however, I want to set a time to send each email.
example: 100 e-mail is sent, the PAUSE script for 1 hour, and sends back another 100 emails.
this code here it sends direct:
=============== code ===============
#!/usr/local/bin/perl
## use: perl enviar.pl lista.txt "remetente@mail.com" "assunto" html.html
$ARGC=@ARGV;
if ($ARGC !=4) {
printf "$0 <mailist> <tes@test.com> <HELLO friend> <html.htm>\n\n";
#printf "Script de envio de e-mails";
exit(1);
}
$mailtype = "content-type: text/html";
$sendmail = '/usr/sbin/sendmail';
$sender = $ARGV[1];
$subject = $ARGV[2];
$efile = $ARGV[0];
$emar = $ARGV[0];
$count=1;
open(FOO, $ARGV[3]);
@foo = <FOO>;
$corpo = join("\n", @foo);
open (BANDFIT, "$emar") || die "Can't Open $emar";
while(<BANDFIT>) {
($ID,
$options) = split(/\|/,$_);
chop($options);
foreach ($ID) {
$recipient = $ID;
open (SENDMAIL, "| $sendmail -t");
print SENDMAIL "$mailtype\n";
print SENDMAIL "Subject: $subject\n";
print SENDMAIL "From: $sender\n";
print SENDMAIL "To: $recipient\n\n";
print SENDMAIL "$corpo\n\n";
close (SENDMAIL);
printf "Enviado para $recipient [ OK $count ]";
$count++;
}
}
close(BANDFIT);
=============== end code ===============
with this code I know I can do this, but could not unite the two codes and make them work.
See:
=============== code ===============
#!/usr/bin/env perl
sub mostraMensagem() {
while(1) {
sleep(1);
print("Hello World!\n");
$count++;
if($count == 5) {
print("PAUSe!\n");
$count = 0;
sleep(5);
print("sending....\n");
mostraMensagem;
}
}
}
mostraMensagem;
=============== end code ===============
Can anyone help me?
I need to make the 2 work ... and send emails slowly according to the txt list
thanks a lot
help, is urgent
|