PHPMailer sending multiple emails to every receipents in database

I am using this code to send email to everyone in the database in a loop. Problem occurred when I find out that user 1 in database also getting all emails sent to other users in the database. User 2 gets all email sent to other users after him and so on. I want to send a single email to everyone customized with their name and emails. Did check and applied couple of solutions from this forum but they are not working.

#SEND EMAILS          require '../includes/PHPMailer/PHPMailerAutoload.php';         require '../includes/PHPMailer/config.php';          if(isset($_POST['submit'])){          $mail = new PHPMailer;          $mail->isSMTP();         $mail->SMTPAuth = true;         $mail->Host = $smtp_server_w;         $mail->Username = $username_w;         $mail->Password = $password_w;         $mail->SMTPSecure = "ssl";         $mail->Port = 465;          $mail->setFrom("[email protected]", "Test Name");          $sql_mail = "SELECT * FROM users";          $run_mail = mysqli_query($conn, $sql_mail);         while ($row_mail = mysqli_fetch_assoc($run_mail)) {          $name = $row_mail["user_name"];         $email = $row_mail["user_email"];         $mail->ClearAddresses();          $mail->addAddress('[email protected]', 'Test Name');          $mail->addBCC($email, $name);          $mail->isHTML(true);  // Set email format to HTML          $bodyContent = "<p>Multiple Messages</p>";          $mail->Subject = $row_mail['user_name'].", New job is available " ;         $mail->Body    = $bodyContent;         $mail->AltBody = $bodyContent;           if(!$mail->send()) {             echo "Message could not be sent.";             $error = '<div class="alert alert-danger"><strong>Mailer Error: '. $mail->ErrorInfo.'</strong></div>';         } else {             $error = '<div class="alert alert-success"><strong>Message has been sent</strong></div>';                 }             }         } 

Replay

Category: php Time: 2016-07-30 Views: 0
Tags: php phpmailer

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.112 (s). 12 q(s)