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
Share on other sites

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"=>"me@mydomain.com", "Subject"=>"Test Mail");
$body = "This is a test!";

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.