Re: High volume e-mailer
| From: | Richard Lynch | Date: | Fri, 05 Jan 2001 06:43:02 +0000 |
| Subject: | Re: High volume e-mailer | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-32836@lists.php.net to get a copy of this message | ||
> 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.
So...
Why could you not do something like this:
create table mailbomb(
email char(32),
mx ip4, #Does MySQL have IP datatype?...
name char(32)
);
Now, I'm pretty sure there's some MX lookup code out there that somebody
(?Manuel Lemos?) wrote, or you could *somehow* look up the MX record for any
given email and maintain this database. Or maybe you could tweak your own
DNS server to do it for you way faster/better. Whatever is best.
Then, you could have a PHP script that did this:
<?php
$query = "select distinct MX from mailbomb";
$mxes = mysql_quer($query) or die(mysql_error());
while (list($mx) = mysql_fetch_row($mxes)){
exec("mxbomb.php $mx &", $result, $errorcode);
#error handling for exec here.
}
?>
--- mxbomb.php ------------
#!/usr/local/bin/php -qf
<?php
$mx = $argv[0]; # Or would that be $argv[1]?
$query = "select email, name from mailbomb where mx = '$mx'";
$victims = mysql_query($query);
$smtp = fsockopen($mx, 25);
while (list($email, $name) = mysql_fetch_row($victims)){
#grungy stuff here to spew each customized email at that SMTP server
#I know that's in Manuel Lemos' email class
}
?>
Obviously, you'll need to add a whole lot of code to handle bounces, and to
re-lookup MX records for those bounces and try again with the new MX (if
it's different) and whatnot...
And you'd have to tweak some kind of delay into the mailbomb.php script to
not have too many processes running... So you might need to track the
forked processes somehow, or just use crude estimates based on number of
emails to a given MX as to how long it will take and keep track of your best
guess of what's running or... I'm sure a real hacker could come up with
some easy way for inter-process communication to report back when an
individual mxbomb finishes...
Am I just being dense? I'm not expecting this to even come *close* to C
code in majordomo or anything, but how is it really different from the #2
suggestion of using Perl and IPC?
If the issue isn't looking up the mail server, but is really about spewing
all the mail for any given MX in one connection, what's so tough for PHP to
do that?
If the real issue is just raw code speed, yeah, C wins over PHP for sure.
But Perl isn't drastically faster than PHP 4 is it?