I need to send email to my 5000 subscribers. What is the best way to do this ?
1) By using BCC ?:
$from_addr = 'myemail@example.com';
$mailing_list = 'sub1@example.com', 'sub2@example.com', 'sub3@example.com0;
$message_subject = 'this is a test';
`$headers = array ("From" => $from_addr,
"Bcc" => $mailing_list,
"Subject" => $message_subject);
$smtp = Mail::factory("smtp", array ('host' => "smtp.example.com",
'auth' => true,
'username'开发者_开发知识库 => "xxx",
'password' => "xxx"));
$mail = $smtp->send($email, $headers, $message_body);`
.
2) by using PEAR mail queue ?
I haven't used PEAR mail_queue yet, but using a queue is definitively the way to go! BCC shouldn't be used because your mails would easily get flagged as Spam by big email providers like gmail/hotmail. Also having thousands of addresses in an email header seems to be crazy. There may even be a limit. Also some mail servers could refuse your mail because of the over-sized header. On top of that the mail server that is supposed to send your email wouldn't be to happy about it.
Using built-in mail
function is not the best way in the first place for that. I would suggest you to go for SwiftMailer which has HTML support, support for different mime types and SMTP authentication which is less likely to mark your mail as spam.
Also, you can check out this pear package:
http://pear.php.net/package/Mail_Queue
精彩评论