Sending an email to over 100k email addresses?
Moderator: General Moderators
Sending an email to over 100k email addresses?
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?
What would be the best way to go about this?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
might need a sleep function
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.

Cheers,
Dibyendra
I'm not confident to say that but this is just my point of view.
Cheers,
Dibyendra
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
Re: Sending an email to over 100k email addresses?
Ew... 100k email spam?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?
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.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: Sending an email to over 100k email addresses?
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).AKA Panama Jack wrote:Ew... 100k email spam?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?
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.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Sending an email to over 100k email addresses?
I was just about to post this topic. Wee..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?
Re: Sending an email to over 100k email addresses?
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.AKA Panama Jack wrote:Ew... 100k email spam?
Re: Sending an email to over 100k email addresses?
Just because I have a popular site that has an excessive amount of email addresses signed up doesn't mean it's spam.AKA Panama Jack wrote:Ew... 100k email spam?
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.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.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
It just so happens I'm in the process of developing one and discussing stuff in Theory & Designphice wrote: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.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.
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();SMTPConnection::connect()
mailer::command()
mailer::getResponse()
mailer::buildMail()
Cheers
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Figures.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).
Can I see your site?Just because I have a popular site that has an excessive amount of email addresses signed up doesn't mean it's spam
Well it certainly looks nice, d11wtqCode: 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();