Advertisement
Guest User

Untitled

a guest
May 6th, 2018
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php
  2.  
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. use PHPMailer\PHPMailer\Exception;
  5.  
  6. require 'vendor/autoload.php';
  7.  
  8. $mail = new PHPMailer(true);
  9. $dotenv = new Dotenv\Dotenv(__DIR__);
  10. $dotenv->load();
  11.  
  12. try {
  13. $login=getenv('MAILER_LOGIN');
  14. $password=getenv('MAILER_PASSWORD');
  15. $mail->SMTPDebug = 0;
  16. $mail->isSMTP();
  17. $mail->Host = 'smtp.gmail.com';
  18. $mail->SMTPAuth = true;
  19. $mail->Username = $login;
  20. $mail->Password = $password;
  21. $mail->SMTPSecure = 'tls';
  22. $mail->Port = 587;
  23.  
  24. $email=$_POST['email'];
  25. $name=$_POST['name'];
  26. $phone=$_POST['phone'];
  27. $description=$_POST['description'];
  28. $who=$_POST['who'];
  29.  
  30. $mail->setFrom($email);
  31. $mail->addAddress('hello@perseids.io');
  32.  
  33. $mail->isHTML(true);
  34. $mail->Subject = 'Formularz kontaktowy perseids.io';
  35. $mail->Body= '<h3>Wiadomość z formularza aplikacyjnego</h3> <b>Email: </b>'.$email."<br/><br/> <b>Imię i nazwisko:</b> ".$name."<br/><br/> <b>Telefon</b>: ".$phone."<br/><br/> <b>Treść wiadomości:</b> ".$description."<br/><br/><b>Kto wypełnił:</b> ".$who;
  36. $mail->send();
  37. } catch (Exception $e) {
  38. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement