We have answer of your question!

100% solved queries, no empty question

Question: Trying to send mail with PHP Mailer and BCC


0

Advertisement


I'm using the plugin "PHPMailer-master" to send email to adresses stored in my db.

I collect all adresses in a string:

$recipients = "mail@mail.com;mail@mail.com;mail@mail.com"; // OR
$recipients = "mail@mail.com,mail@mail.com,mail@mail.com";

Later i set BCC:

$mail->addBCC($recipients);

I also set my mail to get the mail:

$mail->addAddress('my@mail.com');

So, i get no errors... but the only mail that is sent is the one to myself.. what can be the problem? How can i search what's wrong?

UPDATE

This is how i create my string:

while($row = $stmt->fetch()){
    $recipients .= $row['email'] . ";";
}
Question author Bj%c3%b6rn-c | Source

Answer


1


Advertisement


You can not add the mails like this. The Documentation for AddBCC looks like this AddBCC($address, $name = "").
I recommend you to use foreach loop or something similar:

$recipientsArray = explode(";",$recipients); //The delimiter depends on your string that separated the emails
foreach($recipientsArray as $recipient) {
  $mail->addBCC($recipient);
}

Update (Regarding your update)

How you create the Array does not matter. The key point is that the PHPMailer function only accepts one BCC per call. If you fetch it, then you can do it like this:

while($row = $stmt->fetch()){
    $recipients[] = $row["email"];
}
Answer author Luca-jung

Advertisement


Tickanswer.com is providing the only single recommended solution of the question Trying to send mail with PHP Mailer and BCC under the categories i.e php , phpmailer , . Our team of experts filter the best solution for you.

Related Search Queries:

You may also add your answer!