Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once "phpmailer/PHPMailer.php";
- require_once "phpmailer/SMTP.php";
- use PHPMailer\PHPMailer\PHPMailer;
- ?>
- <html>
- <head>
- <meta charset="utf-8">
- </head>
- <body>
- <table>
- <?php
- if ( isset($_POST['sumbit']) ) {
- $tresc = $_POST['tresc'];
- $db = mysqli_connect( "localhost", "root", "", "mailings");
- if ( mysqli_connect_errno() ) {
- echo "Nie można połączyć się z bazą danych".
- die();
- }
- $query = "SELECT * FROM klienci where aktywny=1";
- $result = mysqli_query($db, $query);
- while ( $wiersz = mysqli_fetch_array($result) ) {
- $email = $wiersz['email'];
- $imie = $wiersz['imie'];
- $mail = new PHPMailer;
- $mail->SMTPDebug = 1; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'testtest112154@gmail.com'; // SMTP username
- $mail->Password = 'xxx'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- $mail->setFrom('testtest112154@gmail.com', 'aaa sss');
- $mail->addAddress($email, 'ja'); // Add a recipient
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Mailing od sklepu inted ';
- $mail->Body = " Witaj $imie <br>" . "$tresc" . '<br>' ;
- if( !$mail->send() ) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- echo 'Message has been sent';
- }
- }
- }
- ?>
- <form method="post">
- Podaj tresc:
- <textarea name="tresc">
- </textarea><br>
- <input type="submit" name="sumbit" value="Wyślij">
- </form>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement