RE: [PHP] High volume e-mailer
| From: | Sander Pilon | Date: | Thu, 04 Jan 2001 23:31:06 +0000 |
| Subject: | RE: [PHP] High volume e-mailer | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-32771@lists.php.net to get a copy of this message | ||
> > I have used qmail and ezmlm for this task before but with that
> solution I
> > can't tailor each message with personalized content so I figured I'd
> > rewrite the entire system using PHP.
>
> Sounds reasonable.
>
> > Do any of you know of a good way to feed some 300K e-mails to the MTA
> > without having it choke from the load?
>
> No.
>
> This is where it sounds unreasonable. I don't think *anything* you can do
> will get PHP to scale up to 300K individual emails a day... But I'm no
> expert. Maybe if you had a dedicated machine for it, and enough
> horses, it
> would work...
>
PHP is just not the best tool to do this. (Insert big fat period right
here.)
To send THAT much mail, you need to basically do two things.
1 - Use multiple processes (or better, threads) to send the mail and do the
MX lookups.
2 - Deliver as much as much mail over one connection as possible.
The first task is just not possible in PHP. The second task is possible, and
that's why they bulkmailers sort by mx/tld so that they can open a
connection to that SMTP server and feed it a lot of mails over one
connection instead of making a new connection every time.
> > Should I perhaps do a round-robin kind of thing where I send all e-mails
> > that are addresses to an e-mail address starting with a-f to
> MTA1, g-l to
> > MTA2 and so forth? Better ideas?
>
> Sort the emails by their TLD, I think, is how ezmlm etc do that
> -- Then when
> your server tries to find out where hotmail.com is, it already
> knows 'cuz it
> just looked it up... At least, that's my understanding of it...
> Only that
> assumes you are sending the same message body with a Cc: (or Bcc:) so the
> MTA doesn't have to spew them all out individually in the first
> place... I
> think.
>
Nice try :) However, dns information stays cached for a long while if you
have a decent enough dns server. My guess is that they sort by tld/mx for
the reason given earlier.
My advice is this -
1. Use existing software
2. Or - If you have perl knowledge - use perl. Synchronize multiple
processes using some kind of IPC mechanism. (local sockets, pipes, etc)
2. Or - The solution that will get you the desired results: Get an OO
education and learn some C++, then write it in C++ using threads.
3. Or - do it the oldskool way, use plain C.
Note that you dont HAVE to use multiple processes or threads to achieve
multiple connections, an array of sockets and some select() magic might work
just as well, although a multiplexed solution like that will give you some
other trouble...
(A multiplexed solution might, in theory, maybe perhaps work in PHP - But I
wouldn't waste time trying if you don't know for sure what you are doing.)
-Sander