views:

173

answers:

2

I need to send email to my 5000 subscribers. What is the best way to do this ?

1) By using BCC ?:

  $from_addr = '[email protected]';
  $mailing_list = '[email protected]', '[email protected]', '[email protected];
  $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 ?

+1  A: 

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

Sarfraz
why Bcc is not good ? So you would suggest SwiftMailer or Pear mail_queue indifferently ?Thanks ^_^
xRobot
@xRobot: The SwiftMailer is really good, you should head over to its documentation for more information and feature list.
Sarfraz
+1  A: 

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.

Wolax