Advertisement
Guest User

Untitled

a guest
Jul 30th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #SEND EMAILS
  2.  
  3. require '../includes/PHPMailer/PHPMailerAutoload.php';
  4. require '../includes/PHPMailer/config.php';
  5.  
  6. if(isset($_POST['submit'])){
  7.  
  8. $mail = new PHPMailer;
  9.  
  10. $mail->isSMTP();
  11. $mail->SMTPAuth = true;
  12. $mail->Host = $smtp_server_w;
  13. $mail->Username = $username_w;
  14. $mail->Password = $password_w;
  15. $mail->SMTPSecure = "ssl";
  16. $mail->Port = 465;
  17.  
  18. $mail->setFrom("test@test.com", "Test Name");
  19.  
  20. $sql_mail = "SELECT * FROM users";
  21.  
  22. $run_mail = mysqli_query($conn, $sql_mail);
  23. while ($row_mail = mysqli_fetch_assoc($run_mail)) {
  24.  
  25. $name = $row_mail["user_name"];
  26. $email = $row_mail["user_email"];
  27. $mail->ClearAddresses();
  28.  
  29. $mail->addAddress('test@test.com', 'Test Name');
  30. $mail->addBCC($email, $name);
  31.  
  32. $mail->isHTML(true); // Set email format to HTML
  33.  
  34. $bodyContent = "<p>Multiple Messages</p>";
  35.  
  36. $mail->Subject = $row_mail['user_name'].", New job is available " ;
  37. $mail->Body = $bodyContent;
  38. $mail->AltBody = $bodyContent;
  39.  
  40.  
  41. if(!$mail->send()) {
  42. echo "Message could not be sent.";
  43. $error = '<div class="alert alert-danger"><strong>Mailer Error: '. $mail->ErrorInfo.'</strong></div>';
  44. } else {
  45. $error = '<div class="alert alert-success"><strong>Message has been sent</strong></div>';
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement