Page 1 of 1

Sending mass emails

Posted: Thu Mar 09, 2006 8:11 am
by vnwebworld
Hi all,

I am doing a project for a client, and he has many customers. What he wants is sending to an email list, up to 1 million emails.

I have tried to loop and sent emails but the browser gets timeout. Do you guys have any solution?

I need this quite urgent. Please help me!

Thanks and regards.

Posted: Thu Mar 09, 2006 8:15 am
by jayshields
Use the PEAR mail functions or PHPMailer.

Make sure you're using SMTP too.

Posted: Thu Mar 09, 2006 8:27 am
by vnwebworld
Thanks for fast reply.

I have tried PHPMailer and I am not sure how it can send like 1 million emails. Do you have a sample code?

And one problem with PHPMailer is emails will go to bulk box like AOL or Hotmail. My current solution is relaying through GMail, and PHPMailer cannot support it. Any suggestions?

Thanks for viewing.

Posted: Thu Mar 09, 2006 8:33 am
by Chris Corbyn
vnwebworld wrote:Thanks for fast reply.

I have tried PHPMailer and I am not sure how it can send like 1 million emails. Do you have a sample code?

And one problem with PHPMailer is emails will go to bulk box like AOL or Hotmail. My current solution is relaying through GMail, and PHPMailer cannot support it. Any suggestions?

Thanks for viewing.
Whoaaa... don't try sending 1,000,000 emails in one go from one script unless you hate your SMTP server administrator or you've not had your weetabix this morning 8O

Do them in batches of 100 or so every minute.... much easier.

Posted: Thu Mar 09, 2006 8:39 am
by vnwebworld
Any suggestions for separating? The problem is my client gives me a list of emails like this

email1
email2
...

up to 1 million emails. And I think the time for separating them is also much, and no place to save temporary list also.

Any suggestions ?

Thanks a lot.

Posted: Thu Mar 09, 2006 8:56 am
by feyd

Posted: Thu Mar 09, 2006 8:57 am
by jayshields
just have PHP read the file with the emails in it, explode on line breaks so that they are in an array.

then do a foreach on it, put a counter in the loop and every time it hits a multiple of 100 have PHP sleep for 120 seconds.

it will probably take about half a day to do it all (someone divide a million by 100, times it by 120 and divide it by 60 please, so we know the minutes :P), and i doubt your server admin would like you very much if your on a shared host.

Posted: Thu Mar 09, 2006 9:01 am
by Chris Corbyn
Hmm... I'd actually pull the emails out of the flat file into a database.

I'd then use CRON to run a the mail sending script once a minute and record the addresses that have had emails sent out in the database. You can just have a field called "sent" or suchlike.

Posted: Thu Mar 09, 2006 9:08 am
by vnwebworld
To Feyd: Thanks Feyd, I already take a look at these. I did search the forum before I post this topics.

To jayshields: actually I did not send out email using my hosting smtp. I use GMail to send out. But the time is so much :(

To d11wtq: Thanks man, I also think of this solution but the problem is 1 million email, and 1 minute I send out only 1 email, so I need 1 milliion minutes for 1 category :(.

By the way, how many emails can I add to the BCC field ? I thought of a solution that using cron to send email, each time about 200 or more depending on how many I could add to BCC field.

Any suggestions ?

Thanks all for viewing and giving your suggestions.

Posted: Thu Mar 09, 2006 9:16 am
by vnwebworld
And one more thing is like this forum, if administrator want to send announcements to members through emails, what does it do ? Since I think a good forum like this can get 100000 members.

Any idea ?

Thanks for viewing

Posted: Thu Mar 09, 2006 10:34 pm
by Roja
vnwebworld wrote:And one more thing is like this forum, if administrator want to send announcements to members through emails, what does it do ?
Simple: They don't.

There is a purpose for email - to communicate with someone. There is no practical reason for communicating with a *million* people except commercial use or spam.

If its commercial use, you shouldn't be relying on *gmail*, a free provider to send the emails. If its spam, we have no desire to help.

Worse, we've answered every part of your question. Use phpmailer, read the docs, and you can indeed send *massive* numbers of emails. You can even spread it across multiple smtp servers, speeding up the process. phpmailer also offers the ability to do email batching, yet further speeding it up.

PHPMailer can in fact send with gmail as the smtp server. The "it goes to bulk box" is because you are spoofing the smtp server (you aren't gmail!), and sending BULK EMAIL!

Posted: Fri Mar 10, 2006 1:44 am
by vnwebworld
Roja wrote:
vnwebworld wrote:And one more thing is like this forum, if administrator want to send announcements to members through emails, what does it do ?
Simple: They don't.

There is a purpose for email - to communicate with someone. There is no practical reason for communicating with a *million* people except commercial use or spam.

If its commercial use, you shouldn't be relying on *gmail*, a free provider to send the emails. If its spam, we have no desire to help.

Worse, we've answered every part of your question. Use phpmailer, read the docs, and you can indeed send *massive* numbers of emails. You can even spread it across multiple smtp servers, speeding up the process. phpmailer also offers the ability to do email batching, yet further speeding it up.

PHPMailer can in fact send with gmail as the smtp server. The "it goes to bulk box" is because you are spoofing the smtp server (you aren't gmail!), and sending BULK EMAIL!
Thanks for your reply.

My client and I not going to use this program to spam. The reason why I use Gmail because my client wants me to give him many options. The first option is he will buy a good hosting for sending email and second one is using free smtp server. I also give him notice about not relying on gmail. As a service provider, I just find all solutions and give to my client :)

I will try PHPMailer again, maybe I havent taken a look at it carefully.

Thanks again for your comments.

Posted: Fri Mar 10, 2006 3:12 am
by php3ch0
I send mine in batches of 50 and use sleep(3) to stop timeout

Posted: Sun Mar 12, 2006 10:12 am
by eXpertPHP
You can send 1 milion (or more) of e-mails with XPertMailer very easy. Use for this Bcc, send them a package of 1000 (or less) e-mails to prevent the blocking mode. If you want to send via a Relay SMTP server like Gmail (from trusted host), then i will show you a simple example 'howto':

Code: Select all

<?php

set_time_limit(0);
error_reporting(E_ALL);

// path to XPertMailer.php file 
require_once 'XPertMailer.php';

$mail = new XPertMailer(SMTP_RELAY, 'smtp.gmail.com');

$mail->auth('username@gmail.com', 'password', AUTH_DETECT, SSL_TRUE, 465);
$mail->from('username@gmail.com', 'My Name');

// many e-mail addresses separated by comma and space ...
$header['Bcc'] = 'client1@host1.com, client2@host2.com, client3@host3.com';
$mail->headers($header);

$send = $mail->send('destination@hostname.com', 'subject', 'text/plain message');

echo $send ? "Done." : "Error.";
echo "\nServer response: ".$mail->response;

?>
Execute the script (for preventing timeout on browser) from command line like: php -f /path/script.php
Make sure you have OpenSSL module (extension) enable on your PHP configuration.
Notice: put the real 'From' e-mail address that is the Gmail user account.