how many mails to send @ once?

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
jepe
Forum Newbie
Posts: 5
Joined: Wed Feb 07, 2007 4:01 pm

how many mails to send @ once?

Post by jepe »

hi, this is a kinda refrasing of my previous question ..

(my situation is sort of special with te server i'm at .. so it's celeverer to ask the question in away that
anybody could gain some knowledge from the answer ..)


so .. suppose that I'm sending mail thru a script that's being called by cron ..
my goal is to send as many (in an arrray - to may individual to-s) as fits Swift Mailer .. AT ONCE ..
that it can push thru to the mail system's que in like 10-15 seconds time comfortably ..

how many addresses is "polite" to put in this array as once ..?

my guess is: 50- 100 .. (since it keeps the connection open)
but i can imagine that i could runup to 500 (and only depends on mail server's quota)

what is the cool number then ..?

plz :)

PS: i'm assuming that Swift Mailer has a built in loop ..
and that's what i'm trying to ommit (because of my problem - and not SwfitMailer's:))
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

SwiftMailer does have a loop inside it yes.

The maximum recommended is usally 100. I doubt you'd get 100 emails to a SMTP server in 10 seconds though unless the connection is fast and both servers are fast and fairly idle. It takes bandiwdth and time to process. Also, the more you send, the slower it starts to get. The server will deal with the first few quickly but if you're really flogging it to death it's just going to start crawling while it's resource usage hits the roof.

Many SMTP servers will actually be configured to reject more than 100. Even if you're enveloping all the recipients on the same email (i.e. To:, Cc:) there's a maximum recommended in RFC 2821 of 100 envelopes per message.

I usually say to send 100 emails per batch, then wait *at least* ten seconds before doing the next batch. Ideally you want to be waiting for 1 or 2 minutes though.
jepe
Forum Newbie
Posts: 5
Joined: Wed Feb 07, 2007 4:01 pm

Post by jepe »

well, THANX a LOT !

also I would like to ask if it's a good idea to send one batch in a loop that I create ..

like foreach my_addresses as id=>addsress .... etc ..

with this construction I'd gain that I could log into database after each mail ..

so when my server goes off (or be nice: if it does that) I could start over later from almost exactly where we've just got interrupted ..

I suppose that if I do that with one open connection (per batch - and close it politely)
sending mails one by one could get the same result as passing all the addresses in an array .. couldn't it?


and yet another question: i could, of course put some usleep() into this outer loop ..
should I ..? like a 100?

I have to make a note that I only need "my own loop" - because my server is not that stable ..
otherwise Swift's "inner loop" would be totally fine with me - of course :)

thanx anyhow: Peter
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

That will be *a bit* slower in Version 2 because the caching mechanisms is handled inside send() so it will reset and re-cache each time you iterate. This was yet another one of the improvements Version 3 has brought about, you can use your own loop in version 3 and because the cache is handled by the message itself, you'll still get the optimizations.

Version 3 is still at release candidate phases but I'm 99.9% certain that the PHP5 version will go to full release in it's current state. The PHP4 one is still quite hot-of-the-press but is based on the same codebase.
Post Reply