Gossamer Forum
Home : General : Perl Programming :

Sendmail Loop

Quote Reply
Sendmail Loop
Hi,

I'm currently using a loop to send emails using Sendmail and I'm just wondering if I can only open/close Sendmail once or do I need to open and close it for each email?.....
Quote Reply
Re: [RedRum] Sendmail Loop In reply to
Paul, I don't know a whole lot about sendmail, but I'm pretty sure that yeah, you have to open and close it each time.

That said, I think you could get away with putting multiple addresses into the Bcc: field (blind carbon copy) if you don't care about the recipient being able to see his/her own email address in the To: field, or about being able to customize.

I also think I heard something once about certain ISPs or email services blocking incoming email if the "packets" were over a certain number of emails. The number 20 comes to mind. I have to stress that this may not be in the least accurate, so I'd strongly suggest a throrough investigation.

Also, you may find the Net::SMTP module of interest. (Supposed to be good for higher volumes since it operates via "socket" communications...)

Hope that was *somewhat* helpful, at least... Wink

--
Matt G
Quote Reply
Re: [RedRum] Sendmail Loop In reply to
If you're using a loop, surely you're only opening once (before start of loop) and closing once (after end of loop)?

Wil
Quote Reply
Re: [Wil] Sendmail Loop In reply to
Well that's what I was hoping I could do but thinking about it Sendmail needs to know when to send the email and I think close MAIL; is the line that tells Sendmail to send and so it has to go inside the loop, as does open... to re-open Sendmail.

Mglaspie:

Thanks. I've used Net::SMTP before and it is a possible option but the script may not be used by someone with SMTP capabilities so I need Sendmail as another option.

The script I'm writing is one that allows people to sign up and email a product/website advert to the other members - there are differenct groups who can accept/reject emails from other groups.

I'm actually quite pleased at the moment as I am almost finished writing 3 modules to go with it. Parser.pm, Mailer.pm and Database.pm (It uses MySQL).

Database.pm I'm particularly proud of as it makes SQL queries so easy.

To do a SELECT you'd just do....
Code:
$db->select( TABLE => 'Members',
COLS => ['Username', 'Password'],
);
The resulting query would be:

SELECT Username,Password FROM Members

That's just a simple example.

Last edited by:

RedRum: Sep 26, 2001, 4:51 AM
Quote Reply
Re: [RedRum] Sendmail Loop In reply to
Why reinvent the wheel, Paul? There are numerous modules at CPAN that do exactly that.

Cheers

- wil
Quote Reply
Re: [Wil] Sendmail Loop In reply to
I don't want to use someone elses.

If everyone just used someone elses code no new modules would be developed.

Anyway you get a greater sense of satisfaction writing your own and you can customize it to your needs and more importantly it helps you learn. I'm almost 100% sure I'd learn sweet FA if I downloaded a similar module from CPAN.

Last edited by:

RedRum: Sep 26, 2001, 5:05 AM
Quote Reply
Re: [RedRum] Sendmail Loop In reply to
Granted. But if you are going to make the script commericaly available, or write for a client, then surely using a more sophisticated and proven module would make it faster (might not always be true) and more reliable.

Don't get me wrong. I do exactly the same as you! I was just questioning your motives thats all.

When you've finished, are you going to make them available for DL?
Quote Reply
Re: [Wil] Sendmail Loop In reply to
Quote:
But if you are going to make the script commericaly available, or write for a client, then surely using a more sophisticated and proven module would make it faster (might not always be true) and more reliable.

I have a fairly decent grasp of perl even if I do ask dumb questions here on a regular basis :)

I don't take my own advice and often ask a question before thoroughly investigating.

Quote:
When you've finished, are you going to make them available for DL?

The modules?

Last edited by:

RedRum: Sep 26, 2001, 5:43 AM
Quote Reply
Re: [RedRum] Sendmail Loop In reply to
Yep!
Quote Reply
Re: [RedRum] Sendmail Loop In reply to
Hi,

Normally, yes. However if you call:

/usr/sbin/sendmail -bs

you can use SMTP mode, and send all mail through one connection. This is what GT::Mail::BulkMail does. However, you need to use SMTP, and not just print your email so it's a bit more complex. We've also found a few (< 2%) systems that don't support that flag, so it may not be worth it.

Cheers,

Alex
--
Gossamer Threads Inc.