Hi,

I'm using PHPMailer to send mailout to about 1500 email addresses coming from a database, but i would like to send using BCC , as going through a loop and sending a mail for each address times out.

However i'm a bit stuck on how to get all the email addresses in the BCC i keep getting this error:
Message was not sentMailer Error: Language string failed to load: recipients_failed
when i use the following code

require("class.phpmailer.php");

$sql="
SELECT *
FROM amails
";
$result = mysql_query($sql, $conn)or die(mysql_error());
	while ($row = mysql_fetch_array($result)) {
	//give a name to the fields
	$email=$row['email'];
	$email_id=$row['email_id'];
	$display_block.="$email;";
	}




$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.mysite.com"; // SMTP server
$mail->From = "info@mysite.com";
$mail->FromName = "info@mysite.com";
$mail->AddAddress("me@mysite.com");
$mail->AddBCC("$display_block"); 
//$mail->AddAddress("$email\n");
$mail->AddEmbeddedImage("../images/cover17.jpg", "my", "cover17.jpg");
$mail->IsHTML(true);
$mail->Subject = "Online";

$mail->Body = 'Embedded Image: <img src="cid:my" alt="cover" >'; 
$mail->Body = "
<table width=\"500\" border=\"1\" align=\"center\" cellpadding=\"3\" cellspacing=\"4\" bordercolor=\"#CCCCCC\" bgcolor=\"#FFFFFF\">
<tr><td><a href=\"http://www.mysite.com/comments/unsubscribe.php?unsubscriber=$email_id\">Click here</a> to remove your address from this mailing list</td></tr>
</table>";
$mail->WordWrap = 50;


if(!$mail->Send())
{
   echo "Message was not sent";
   echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
  $display_block= " meassage sent to $email\n";
}

I'm not quite sure how i get all the addresses in to the BCC. Help would be greatly appreciated.

    3 months later

    I'm doing some research on a different phpmailer / BCC issue but since I had the same issue as this post, thought I'd reply with what I did to fix it.

    The phpmailer package has three essential files:

    class.phpmailer.php
    class.smtp.php (optional - only needed for SMTP)
    language file: phpmailer.lang-en.php (English althought there are a bunch of others)

    In the phpmailer instructions (http://phpmailer.sourceforge.net) you're supposed to add these files to the php.ini includes path. Instead I just referenced as includes at the top of my scripts.

    include_once("lib/phpmailer/class.phpmailer.php");
    include_once('lib/phpmailer/language/phpmailer.lang-en.php') ;

    I was getting the same error (Language string failed to load) until I added the second include for the phpmailer.lang-en.php language file. Once I did that, the mailer worked fine with no error messages.

      a year later

      I was running into the same problems and looked into all sorts of fixes.
      I was pulling the from address from a database and that from address was not an address on the server. Therefore there was a security issue that was not allowing the phpmailer function to work, and giving the error message in question.

      What I found if the following:

      The From address should be the email address you are using for the smtp authentication.
      You can use
      this->AddReplyTo("$fromaddress", "$fromaname");
      to set the reply to address to whatever address you like, particularly the person sending the email.

      The complete function looked like this:

      $mail = new PHPMailer();

      $mail->IsSMTP();

      $mail->Host = "somehostcom";

      $mail->SMTPAuth = true; // turn on SMTP authentication
      $mail->Username = "some@email.com"; // SMTP username
      $mail->Password = "somepassword"; // SMTP password

      $mail->From = "some@email.com";
      $mail->FromName = "$fromname";
      $mail->AddAddress("$contactemail","$contactname");
      $mail->AddReplyTo("$fromaddress", "$fromname");

      of course in this scenario, the $mail would be replaced by $this.

        2 years later
        Write a Reply...