Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PHPMailer\PHPMailer\PHPMailer;
- require 'PHPMailer.php';
- require 'SMTP.php';
- $errors = [];
- if (isset($_POST['submit'])) {
- $msg = '';
- //post adatok kezelése...///
- $email = $_POST['email']; //email ellenőrzést a példában kihagytam
- $body = $_POST['body'];
- if (empty($errors)) {
- $to = "mymail@gmail.com";
- $mail = new PHPMailer;
- $mail->isSMTP();
- $mail->Host = 'smtp.gmail.com';
- $mail->Port = 587;
- $mail->setFrom('contact@example.com');
- $mail->addAddress($to);
- $mail->addReplyTo($email);
- // $mail->Username = 'sender@example.com'; ide mit kell?
- // $mail->Password = 'password'; ide mit kell?
- $mail->Subject = 'Mysubject';
- $mail->Body = $body;
- if (!$mail->send()) {
- $msg .= 'Mailer Error: '. $mail->ErrorInfo;
- } else {
- $msg .= 'Message sent!';
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement