LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-18-2014, 02:38 PM   #1
willsilva8611
LQ Newbie
 
Registered: Sep 2014
Posts: 3

Rep: Reputation: Disabled
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
 
Old 09-18-2014, 02:43 PM   #2
aatif
LQ Newbie
 
Registered: Sep 2014
Posts: 4
Blog Entries: 4

Rep: Reputation: 0
nice work
 
Old 09-18-2014, 03:04 PM   #3
willsilva8611
LQ Newbie
 
Registered: Sep 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
but could not make it work over time, can help me?
 
Old 09-18-2014, 04:45 PM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Just curious, why the need to send 100 emails per hour?
 
Old 09-19-2014, 07:12 AM   #5
willsilva8611
LQ Newbie
 
Registered: Sep 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Reply

per hour is just one example. do not want to overload the server and improve delivery. my database are 5,000 emails and do Daily sendings mails
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to do a pause in a perl script? abefroman Programming 2 01-29-2009 01:44 PM
Running a Perl script with SendMail NewByy Linux - Newbie 4 08-25-2005 01:02 PM
Running a Perl script with SendMail NewByy Programming 2 08-25-2005 09:56 AM
OUCH! Perl Sendmail script looped over 14000 times to 1 addy... HELP! brokenfeet Programming 1 09-04-2003 07:51 PM
set content-type to 'text/html' in sendmail, using perl script brokenfeet Programming 3 08-05-2003 02:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration