SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Mass mailing comments
-
May 13, 2003, 14:35 #1
- Join Date
- May 2002
- Location
- London
- Posts
- 301
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Mass mailing comments
Just wondered if anyone has had any experience writting/ using a PHP script that handles large (5,000 +) mailing lists. This is what I've written so far for the sending -
PHP Code:$mail = new phpmailer();
$mail -> IsSMTP();
$mail -> Host = "mailserver.domain.com";
$mail -> From = "from@email.com";
$mail -> Subject = "free spam";
$db = new MyDatabase($dbEzine, $dbServer);
$db -> connect($user, $pass);
$sql ="
SELECT
EmailAddress,
SubscriberFormatPK
FROM
Email,
Subscribe
WHERE
SubscriberNewsletterPK = ".$this -> input['topic']."
AND
SubscriberLanguagePK = ".$this -> input['lang']."
";
$result = $db -> query($sql);
$q = new QueryIterator($result);
set_time_limit(0);
$counter = 0;
while($records = $q -> getCurrent())
{
$mail -> AddAddress($records['EmailAddress']);
$mail -> Body = "hi ! \n\n enjoy your free spam; sent daily.";
$mail -> WordWrap = 50;
if(!$mail -> Send())
{
echo 'Message was not sent - '.$records['EmailAddress'].'<br>';
echo 'Mailer Error: ' . $mail -> ErrorInfo.'<br>';
}
else
{
echo 'Message sent - '.$records['EmailAddress'].'<br>';
}
$mail -> ClearAddresses();
$counter ++;
if (($counter % 50) == 0)
{
sleep(30);
}
$q -> next();
}
Any additional comments/ tips would be most greatful.
-
May 15, 2003, 01:23 #2
- Join Date
- Feb 2003
- Posts
- 156
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
to connect directly to the SMTP server; so avoiding the slow mail() function
If you are sending large numbers of emails, it is a lot easier on the server if you are using BCC to send a single email to x users at once.
Also in terms of performance it is important how well the MTA is configured (e.g. http://www.sendmail.org/~ca/email/doc8.12/TUNING )
Sorry, if I cannot be of more help. If you search for "mass mailing" in these forums you will find a couple interesting topics in this like: http://www.sitepointforums.com/showt...ight=mass+mail
-
May 22, 2003, 01:37 #3
- Join Date
- May 2002
- Location
- London
- Posts
- 301
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If you are using you local MTA, I wonder if there really is such a big difference. Do you know if anybody has actually measured such things?
If you are sending large numbers of emails, it is a lot easier on the server if you are using BCC to send a single email to x users at once.
I'm interested with your comments concerning BCC, I was under the impression that the server still had to send each email individually regardless of being sent via BCC, are there not limits to how many you can add?
Bookmarks