To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Coding

Coding Help with PHP coding

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 12-15-2005, 02:50 PM   #1
ali_p
Senior Member
 
ali_p's Avatar
 
Join Date: Oct 2003
Posts: 195
Help with PHPMailer and BCC

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

PHP 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.
ali_p is offline   Reply With Quote
Old 03-29-2006, 06:51 PM   #2
ncracraf
Member
 
ncracraf's Avatar
 
Join Date: Oct 2005
Location: Campbell, CA
Posts: 34
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.

PHP Code:
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.
ncracraf is offline   Reply With Quote
Old 03-31-2007, 01:19 PM   #3
kscinc
Junior Member
 
Join Date: Mar 2007
Posts: 1
Possible Solution

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.
kscinc is offline   Reply With Quote
Old 06-10-2009, 06:18 PM   #4
jamarchi
Junior Member
 
Join Date: Jun 2009
Posts: 4
Hi ali_p

Did you fix this problem ?
jamarchi is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 07:34 AM.








Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.