* Thus wrote Mohanaraj ([EMAIL PROTECTED]):
> Dear all,
> 
> I have read that using mail() in a for loop to send a lot of emails (
> around 1k-10k ) emails is not advised due to the fact that it can be
> resource intensive hence or the script might take so much time that it
> ti,es out. However what if i append all the emails into the Bcc: header
> as follows and make only 1   call to mail.

Its not the mail() function itself that is resource intensive.  It
is when you rapidly send 10k messages to a mailserver it has to
queue them up (move them to a queue folder.) Then, usually the queue
manager goes through the queue and sends each one individually.

This is one of the reasons why ISP's don't allow spamming on their
servers. It puts heavy loads on their servers and delays everyone
else's mail while your 10k messages get processed.


> 
> 1. Is this better?
> 2.Will it still be resource hungry?

1. no
2. yes

The reason being is that when you bcc mail, the mail client
(php being the client in this case) prepares a separate message for
each bcc user, thus the same effect of loading down the mailserver
occurs.

> 3.What would be the best way to handle mailing to many email addresses
> from PHP. This is for a newsletter (not SPAM) application I am working on.

I think the best approach in sending a large amount of mail out at
one time, would bet to send them out in little bursts (1-5
messages) and have php sleep (like 1-2 seconds) in between, so the
mailserver can breath a little.

If you send out 1 mail per second with 10k emails, that would come
to about 2.7 hours spent sending.  That might seem like a long time
but considering the risks, loosing your mail account or loading
down the mailserver etc.., it is a very low cost IMO.

To get around the timeout issue, you can use the set_time_limit()
function.

> 4.How does this compare against using sockets to directly speak to the
> SMTP server from a efficiency aspect?

Talking directly to an SMTP server is error prone, unless your up
on the SMTP protocol specs.  And besides it wont change any of the
heavy load the mail server will get.

I would recommend sticking with mail() or some other already
existing package that sends mail.


HTH,

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to