Page 1 of 2

Sending an email to over 100k email addresses?

Posted: Tue May 02, 2006 12:30 am
by phice
How would I go about sending out an email to over 100,000 email addresses? I've heard that mail() isn't too reliable and I should use SMTP or the like?

What would be the best way to go about this?

Posted: Tue May 02, 2006 12:37 am
by Christopher
You might want to use a service. Try Googling "bulk email service". I have clients that have had a good experience with Constant Contact, but there are many others.

Posted: Tue May 02, 2006 12:49 am
by phice
I'd prefer to do it locally (free) if at all possible.

Posted: Tue May 02, 2006 12:53 am
by feyd
The basics are set up a cron to run a batching file that sends 10 or 100 at a time through your SMTP server using a class such as phpMailer.

Posted: Tue May 02, 2006 1:50 am
by Christopher
For free you can also use phpList.

might need a sleep function

Posted: Tue May 02, 2006 1:54 am
by dibyendrah
sending the mail over 10,000 at once will make the SMTP go mad.. So, what we can do is put the sleep(1) after each mail() function will keep the SMTP cool.
I'm not confident to say that but this is just my point of view.
:lol:

Cheers,
Dibyendra

Posted: Tue May 02, 2006 3:58 am
by Chris Corbyn
phpMailer can handle bulk emailing yes.... the basic principle, if you want to do it yourself, is to use fsockopen() to establish a connection with the server. Then you loop over all your email addresses sending out the appropriate SMTP commands (via fwrite()) to deliver the email.

Re: Sending an email to over 100k email addresses?

Posted: Tue May 02, 2006 6:18 am
by AKA Panama Jack
phice wrote:How would I go about sending out an email to over 100,000 email addresses? I've heard that mail() isn't too reliable and I should use SMTP or the like?

What would be the best way to go about this?
Ew... 100k email spam?

You really don't want to use the mail() for something like that. Mail() will usually WAIT for a response indicating if the mail was sent to the address or not. Depending upon the server and connection you might be lucky to send an email every second. :)

Re: Sending an email to over 100k email addresses?

Posted: Tue May 02, 2006 7:31 am
by Chris Corbyn
AKA Panama Jack wrote:
phice wrote:How would I go about sending out an email to over 100,000 email addresses? I've heard that mail() isn't too reliable and I should use SMTP or the like?

What would be the best way to go about this?
Ew... 100k email spam?

You really don't want to use the mail() for something like that. Mail() will usually WAIT for a response indicating if the mail was sent to the address or not. Depending upon the server and connection you might be lucky to send an email every second. :)
It's not just that... mail() opens a new connection to the server for each and every email it sends... this is slow. If you can use a single connection to send any number of emails things will be much faster. You can just say HELO/EHLO once, then repeatedly go "mail from:", "rcpt to", "data". I can't remember why but emails sent via mail() are often rejected as spam too... though this would usually be down to the content of the email (including the headers).

Re: Sending an email to over 100k email addresses?

Posted: Tue May 02, 2006 8:42 am
by John Cartwright
phice wrote:How would I go about sending out an email to over 100,000 email addresses? I've heard that mail() isn't too reliable and I should use SMTP or the like?

What would be the best way to go about this?
I was just about to post this topic. Wee.. 8)

Re: Sending an email to over 100k email addresses?

Posted: Tue May 02, 2006 11:12 am
by onion2k
AKA Panama Jack wrote:Ew... 100k email spam?
Just because it's a big list doesn't immediately mean it's spam. I've used to have a client with over 250k addresses.. I used Perl and a batching system to do each send. The latest version of my code can do a sustainable 10 emails customised with individual names and stuff per second.

Re: Sending an email to over 100k email addresses?

Posted: Tue May 02, 2006 11:45 am
by phice
AKA Panama Jack wrote:Ew... 100k email spam?
Just because I have a popular site that has an excessive amount of email addresses signed up doesn't mean it's spam. :)

Posted: Tue May 02, 2006 11:46 am
by phice
d11wtq wrote:phpMailer can handle bulk emailing yes.... the basic principle, if you want to do it yourself, is to use fsockopen() to establish a connection with the server. Then you loop over all your email addresses sending out the appropriate SMTP commands (via fwrite()) to deliver the email.
Could you point me in the direction of what to use for the fsockopen or even an example script? Too bad EvilWalrus isn't still around.

Posted: Tue May 02, 2006 12:13 pm
by Chris Corbyn
phice wrote:
d11wtq wrote:phpMailer can handle bulk emailing yes.... the basic principle, if you want to do it yourself, is to use fsockopen() to establish a connection with the server. Then you loop over all your email addresses sending out the appropriate SMTP commands (via fwrite()) to deliver the email.
Could you point me in the direction of what to use for the fsockopen or even an example script? Too bad EvilWalrus isn't still around.
It just so happens I'm in the process of developing one and discussing stuff in Theory & Design :P

viewtopic.php?p=259919#259919

You can maybe even try just using the code as it is if you wanted but I warn you that it's not fully tested (and it's PHP5). It would be easy enough to change to PHP4.

To send a batch email you'd do:

Code: Select all

$addresses = array(
    'one@domain.com',
    'two@domain.com',
    'three@domain.com'
);

$mailer = new mailer(new SMTPConnection('smtp.your-isp.com'), 'yourdomain.com');

$mailer->addPart('<strong>some html</strong>', 'text/html');
$mailer->addPart('some plain text');
$mailer->send($addresses, 'your@address.com', 'The subject');
$mailer->close();
If you're just looking for the logic then look at the methods:

SMTPConnection::connect()
mailer::command()
mailer::getResponse()
mailer::buildMail()

Cheers :)

Posted: Tue May 02, 2006 6:25 pm
by Ollie Saunders
I can't remember why but emails sent via mail() are often rejected as spam too... though this would usually be down to the content of the email (including the headers).
Figures.
Just because I have a popular site that has an excessive amount of email addresses signed up doesn't mean it's spam
Can I see your site?

Code: Select all

$addresses = array(
    'one@domain.com',
    'two@domain.com',
    'three@domain.com'
);

$mailer = new mailer(new SMTPConnection('smtp.your-isp.com'), 'yourdomain.com');

$mailer->addPart('<strong>some html</strong>', 'text/html');
$mailer->addPart('some plain text');
$mailer->send($addresses, 'your@address.com', 'The subject');
$mailer->close();
Well it certainly looks nice, d11wtq