Problematic delay in script

D

\Dandy\ Randy

Hello, I have created a mailing program for our company that sends out
emails to our client database. There seems to be a delay in the script or
the processing of the emails. Here is how it works. The email addresses are
stored in a simple text file, one on top of each other. Each email is sent
through a foreach loop. I use this code to get email addresses and send the
emails:

open (ADDRESSES, "<address.txt") or die "Can't open file: $!";
@list=<ADDRESSES>;
close(ADDRESSES);

$mailprog="/usr/sbin/sendmail -t";

foreach $list (@list) {
chomp ($list);
($name,$email)=split(/\|/,$list);

open (MAIL, "|$mailprog") or die "Can't open main program: $!";
print MAIL "From: $adminname <$adminemail>\n";
print MAIL "To: $fullname <$email>\n";
print MAIL "Subject: $subject\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "X-MSMail-Priority: $priority\n";
print MAIL "Content-Type: multipart/alternative;\n";
print MAIL " boundary=\"separator\"\n\n";
print MAIL "This is a multi-part message in MIME format.\n\n";
print MAIL "--separator\n";
print MAIL "Content-Type: text/plain;\n";
print MAIL " charset=\"iso-8859-1\"\n\n";
print MAIL "@textonly\n\n";
print MAIL "--separator\n";
print MAIL "Content-Type: text/html;\n";
print MAIL " charset=\"iso-8859-1\"\n\n";
print MAIL "@content\n\n";
print MAIL "--separator--";
close (MAIL);
}

print "Confirmation Message";

For testing purposes, the address.txt file contains 100 email addresses ...
all different, but in the end end up in my inbox ... so if I recieve 100
emails the script works. Well it does ... I do get the 100 emails but heres
the thing ... almost right away I get about 60-70 emails ... but then the
other 30 seem to get delivered at random intervals. Some take 5 minutes,
some take 5 hours. I am puzzled why so many take so long to get delivered?
Am I overloading sendmail? or maybe my email account? Your
thoughts/reccommendations are appriciated.

Randy
 
B

Beau Schwabe

Just for test... try halving your database....i.e. send two chunks of
50 emails. Does the first 50 go through ok? The second? or does it
stop at 20 or so and spit the remainder 30 out at intermittent
intervals?

-Beau Schwabe
 
T

Tad McClellan

\"Dandy\" Randy said:
print MAIL "@content\n\n";


That adds space characters to the body of the email message.

Is that what you want it to do?



perldoc -q spaces

Why do I get weird spaces when I print an array of lines?
 
D

\Dandy\ Randy

Yes, this \n\n is required at the end of the html body content, otherwise
the multipart html will send process the separators correctly.
 
D

\Dandy\ Randy

use Mail::Bulkmail;

I do not believe my hosting company had this module installed.

R
 
D

David K. Wall

[TOFU rearranged to proper chronological order. Please don't do
that.]

Yes, this \n\n is required at the end of the html body content,
otherwise the multipart html will send process the separators
correctly.

The "\n\n" is not what Tad was talking about. If you read the FAQ
entry he referred to you'll see what Tad was asking.
 
D

\Dandy\ Randy

Beau Schwabe said:
Just for test... try halving your database....i.e. send two chunks of
50 emails. Does the first 50 go through ok? The second? or does it
stop at 20 or so and spit the remainder 30 out at intermittent
intervals?

Beau, I did a test a you suggested ...

Test #1
Sent: 50 emails all to my inbox
Result: All 50 delivered timely ... within 30 seconds

--- Waiting 2 minutes before next test

Test #2
Sent: 50 emails all to my inbox (again, same addresses)
Result: 49 delivered timely ... within 30 seconds. 1 email has not arrived.
most likely will at some point

--- Waiting 2 minutes before next test

Test #3
Sent: 100 emails all to my inbox (same addresses)
Result: 85 delivered timely ... within 30 seconds. 15 emails have not
arrived.
 
C

Chief Squawtendrawpet

\"Dandy\" Randy said:
Sam, I don't actually have perl installed locally, so I dont have access to
perldoc information other than what I find on www.perldoc.com ... could you
post instruction? TIA!

You're not trying very hard. If you've got access to the documentation
on the web, go to the FAQ and try searching for the obvious: "install"
(success on the first hit) or "module" (third hit) or "CPAN" (first
hit) ...

Chief S.
 
E

Eric Schwartz

\"Dandy\" Randy said:
Sam, I don't actually have perl installed locally, so I dont have access to
perldoc information other than what I find on www.perldoc.com ... could you
post instruction? TIA!

Perl can be installed on every operating system I personally can
conceive of you actually running. So go out and install it today!
Among the many benefits, you will gain the ability to test your perl
programs before uploading them to your hosting provider (This is so
useful, I can't imagine why anybody would not want to do this), and a
local copy of the latest and greatest Perl documentation that you are
guaranteed matches what is installed.

I'm not going to bother posting the URL on perldoc.com because:

A) Somebody else probably will anyway.
B) You're more than capable, and unlike me, you care.

But it's on there. Have fun.

-=Eric
 
S

Sam Holden

Sam, I don't actually have perl installed locally, so I dont have access to
perldoc information other than what I find on www.perldoc.com ... could you
post instruction? TIA!

The Laziness virtue is about reducing overall work, not reducing your own work
by getting others to do trivial things for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top