Jump to content

Sending mail() to 2000+ users


.Darkman

Recommended Posts

Hello,

 

I have a database of over 2000 users. I wish to send newsletters to them via PHP's mail() function.

 

What is the best way to do ?

 

I'm asking this because, i read somewhere that using the mail() for a large number of users can crash the server.

So, whats the best way to do it ? I'm on Shared hosting.

 

 

Thanks,

Shrihari.S

Link to comment
https://forums.phpfreaks.com/topic/92896-sending-mail-to-2000-users/
Share on other sites

i would suggest looking at the PEAR Mail package, i believe its more 'Reliable'.

 

i dont know anything about it though i wish i could be more help, try this link:

http://pear.php.net/package/Mail

 

 

hope this helps,

I'll take a look... thx :)

 

best move is to batch action it into 100-200 emails at a time

How do i do that ?

Actually, php.net/mail says that it is better to use PEAR package for large volume of mailing.

So, is the following code good ? Or, does this also put a lot of stress on the server ?

<?php

include ('/home/username/php/Mail.php');

$mail = Mail::factory("mail");

$headers = array("From"=>"[email protected]", "Subject"=>"Test Mail");
$body = "This is a test!";

foreach($emails AS $email)
{
// about 2500 email addresses
$mail->send($email, $headers, $body);
}
?>

personally ive never used pear but i can give u a tip.

 

time the script AND each email using microtime(). This will tell you roughly how much time it takes to complete the operations.

during that time look at your processor usage and memory usage. while the script is running try to run another one along-side etc, there are numerous ways to stress test a script.

 

the script looks good to me. have you tried it are there any errors?

personally ive never used pear but i can give u a tip.

 

time the script AND each email using microtime(). This will tell you roughly how much time it takes to complete the operations.

during that time look at your processor usage and memory usage. while the script is running try to run another one along-side etc, there are numerous ways to stress test a script.

 

the script looks good to me. have you tried it are there any errors?

 

 

Run time/memory usage aren't the concerns here its being labeled a spammer that will happen if you are found to  send 2000 emails in less than a minute you have to spread it out over hours unless you have a security certificate or are on some sort of white list.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.