Page 1 of 1

Best method of bulk sending email newsletters

Posted: Tue Jun 03, 2003 4:04 am
by PaulCreedy
I would like to bulk send a newsletter to subscribers to my site. I currently do this on my local machine by downloading the list and using a desktop app to send the newsletter from my computer.

My host isn't so keen on bulk sending from the host because of the CPU load, etc. and the possibility that some sites may see a bulk send as spam and block the IP.

I'm looking for recommendations on the most efficient way of sending mail from the site and the pro's and con's of the different methods. ie Looping through each mail and sending individually, BCC sending, mailing list servers, etc.

I'm an ASP to PHP convert, so I'm still in the learning stage of PHP, but I can use the mail() function.

What methods do you use/recommend?

Thanks

Posted: Tue Jun 03, 2003 4:17 am
by volka
ask your provider wether they are willing to install a group list for you (or already have).
That way you would maintain a list of group members and send your newsletter to this group. The server will handle the recipient list which might take less performance.
Always include a working unscribe link and ask your provider wether common X-headers for spam spoofing are enabled

Posted: Tue Jun 03, 2003 8:01 am
by nielsene
Well here's the code I use, inspired by similar code in the SourceForge.Net 2.5 baseline (before they changed from GPL to closed-source). On my site I use this for allowing the people running a given hosted event to broadcast a message to their event attendees. (Often in the 200-400 people range)

Code: Select all

function spamList($addresses,$subject,$body,$from,$headers="")
{
  global $CIB_HOSTNAME, $CIB_DOMAIN, $CIB_SERVER_ADMIN_EMAIL;
  $addresses = array_unique($addresses);
  $numAddresses = count($addresses);
  $to = "no-reply@$CIB_HOSTNAME{$CIB_DOMAIN}";
  $bcc = "";
  $body .=<<<END_TAGLINE
\n\nThis message is sent to you through the competitor notification
service of the CompInaBox server running at $CIB_HOSTNAME{$CIB_DOMAIN}.   Use for any
purpose unrelated to the competition in question is strictly prohibited.
Please notify the server administrator at $CIB_SERVER_ADMIN_EMAIL to report
abuse.
END_TAGLINE;
  if ($headers!="")    $headers="X-mailer: CompInaBox via PHP\r\n$headers";
  else
    $headers="X-mailer: CompInaBox via PHP";
  for ($i = 0; $i < $numAddresses; $i++)
    {
      if ($i % 25 == 24)
	{
	  mail($to,$subject,$body,
	       "From: $from\r\nbcc:$bcc\r\n$headers");
	  $bcc="";
	}
      $bcc .= ($bcc=="" ? "" :", ") . $addresses[$i];
    }
  if ($bcc!="")
    mail($to,$subject,$body,
	 "From: $from\r\nbcc: $bcc\r\n$headers");
}
Breaking up each mailing into batches of 25 tends to make host providers happier as it lessens the load of any one process and gives the scheduler an easier swap job.

Posted: Tue Jun 03, 2003 8:57 am
by Takuma
I just looped the mail function so it sends e-mail to everyone.

->nielsene

That's a pretty cool script, do you have the actual script by SourceForge?

Posted: Tue Jun 03, 2003 9:02 am
by nielsene
The actual SourceForge script can be found at multiple places on SourceForge.net and other places. Here's a link to the last open source version of that file.

Really long URL, which would break the forum

Posted: Tue Jun 03, 2003 9:02 am
by Takuma
Thanks :D

nielsene

Posted: Tue Jun 03, 2003 10:49 am
by owen
nielsene since we're on the topic of email - what about batching the emails and then sending them out? For example you have a forum. would it be best batch the emails and then check for spam before sending them out. Or send them out instantly and have fload control?

Posted: Tue Jun 03, 2003 10:53 am
by nielsene
Well the method I posted does the mass mailing in mini batches. But I think you are talking about batching multiple different emails? In which case I beleive that ceases to be a PHP issue and is something that your local mail server handles automatically. I know EXIM on my local server handles the "flood control" aspect.

And as very few people have permission to send email via my page I don't worry about spam. I'm one of three providers of the service I provide and people play by my rules rather than use the option of using it....