Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
4,126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2. use PHPMailer\PHPMailer\PHPMailer;
  3. require 'PHPMailer.php';
  4. require 'SMTP.php';
  5.  
  6. $errors = [];
  7.  
  8. if (isset($_POST['submit'])) {
  9.     $msg = '';
  10.     //post adatok kezelése...///
  11.     $email = $_POST['email']; //email ellenőrzést a példában kihagytam
  12.     $body = $_POST['body'];
  13.  
  14.   if (empty($errors)) {
  15.  
  16.     $to = "mymail@gmail.com";
  17.     $mail = new PHPMailer;
  18.     $mail->isSMTP();
  19.     $mail->Host = 'smtp.gmail.com';
  20.     $mail->Port = 587;
  21.        
  22.     $mail->setFrom('contact@example.com');
  23.     $mail->addAddress($to);
  24.     $mail->addReplyTo($email);
  25.     // $mail->Username = 'sender@example.com';  ide mit kell?
  26.     // $mail->Password = 'password';    ide mit kell?
  27.     $mail->Subject = 'Mysubject';
  28.     $mail->Body = $body;
  29.         if (!$mail->send()) {
  30.             $msg .= 'Mailer Error: '. $mail->ErrorInfo;
  31.         } else {
  32.             $msg .= 'Message sent!';
  33.         }
  34.   }
  35.  }
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement