Is it reasonable to use the mail function to send 3000 mails

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
spartan7
Forum Commoner
Posts: 29
Joined: Sun Jun 19, 2005 12:09 am

Is it reasonable to use the mail function to send 3000 mails

Post by spartan7 »

Hi all

Is it reasonable to use the mail function to send 3000 mails at a time?

If I have 3000+ contacts in my database and I need to send email emails, what is the best way of doing it? I havnt used the mail function to send to so many people before and I'm wondering if its reasonable to do so.

Thanks
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Not if you can avoid it? PHP mail function isn't the most efficient way to send mail.

Shared host? Well if your on a shared host, they'll either not want you to be sending that many emails or want you to break them up. Send 5, wait a minute, send 5 more sort of thing. You do search here you might find some code.

3000 is a lot. You should ask your host.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

The problem with the mail() function is that it opens a connection to the mail server, sends, then closes it again. If you're sending a lot that's a horrible way of doing things. It's much better to open a connection, send all the emails, and then close it. The old version of my email marketing app did that and regularly sent batches of 10,000 HTML emails .. I think the record is around 15,000.

However, even that got to be a bit intensive on the server, and took ages to run, so I rewrote it in Perl. 160,000 emails .. no problem. And it's pretty quick too .. it averages around 10/second with full customisation. I'm sure I could get it going faster though, there's still some old unoptimized code in there. Just don't have the time these days.
User avatar
dbevfat
Forum Contributor
Posts: 126
Joined: Tue Jun 28, 2005 2:47 pm
Location: Ljubljana, Slovenia

Post by dbevfat »

onion2k wrote:The problem with the mail() function is that it opens a connection to the mail server, sends, then closes it again. ...
Actually it's not always like this. On majority of linux servers the mail() function just queues the mail locally and returns true if the queueing was successfull. The actual sending from the queue is done by another process.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

dbevfat wrote:
onion2k wrote:The problem with the mail() function is that it opens a connection to the mail server, sends, then closes it again. ...
Actually it's not always like this. On majority of linux servers the mail() function just queues the mail locally and returns true if the queueing was successfull. The actual sending from the queue is done by another process.
I didn't realise that myself :) I know that on *nix servers the "path_to_sendmail" is used so it does make sense.
Post Reply