Advertisement
Guest User

wyslij.php

a guest
Oct 27th, 2018
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. <?php
  2. require_once "phpmailer/PHPMailer.php";
  3. require_once "phpmailer/SMTP.php";
  4. use PHPMailer\PHPMailer\PHPMailer;
  5. ?>
  6.  
  7. <html>
  8. <head>
  9. <meta charset="utf-8">
  10. </head>
  11. <body>
  12.  
  13. <table>
  14. <?php
  15.  
  16. if ( isset($_POST['sumbit']) ) {
  17. $tresc = $_POST['tresc'];
  18.  
  19. $db = mysqli_connect( "localhost", "root", "", "mailings");
  20. if ( mysqli_connect_errno() ) {
  21. echo "Nie można połączyć się z bazą danych".
  22. die();
  23. }
  24.  
  25. $query = "SELECT * FROM klienci where aktywny=1";
  26. $result = mysqli_query($db, $query);
  27.  
  28. while ( $wiersz = mysqli_fetch_array($result) ) {
  29. $email = $wiersz['email'];
  30. $imie = $wiersz['imie'];
  31.  
  32. $mail = new PHPMailer;
  33. $mail->SMTPDebug = 1; // Enable verbose debug output
  34. $mail->isSMTP(); // Set mailer to use SMTP
  35. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  36. $mail->SMTPAuth = true; // Enable SMTP authentication
  37. $mail->Username = 'testtest112154@gmail.com'; // SMTP username
  38. $mail->Password = 'xxx'; // SMTP password
  39. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  40. $mail->Port = 587; // TCP port to connect to
  41. $mail->setFrom('testtest112154@gmail.com', 'aaa sss');
  42. $mail->addAddress($email, 'ja'); // Add a recipient
  43. $mail->isHTML(true); // Set email format to HTML
  44. $mail->Subject = 'Mailing od sklepu inted ';
  45. $mail->Body = " Witaj $imie <br>" . "$tresc" . '<br>' ;
  46.  
  47. if( !$mail->send() ) {
  48. echo 'Message could not be sent.';
  49. echo 'Mailer Error: ' . $mail->ErrorInfo;
  50. } else {
  51. echo 'Message has been sent';
  52. }
  53. }
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. }
  61.  
  62.  
  63. ?>
  64.  
  65. <form method="post">
  66. Podaj tresc:
  67. <textarea name="tresc">
  68. </textarea><br>
  69. <input type="submit" name="sumbit" value="Wyślij">
  70. </form>
  71. </table>
  72. </body>
  73.  
  74. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement