Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?php
  2.  
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. use PHPMailer\PHPMailer\Exception;
  5.  
  6. require 'PHPMailer-master/src/Exception.php';
  7. require 'PHPMailer-master/src/PHPMailer.php';
  8. require 'PHPMailer-master/src/SMTP.php';
  9.  
  10. $mail = new PHPMailer();
  11. $mail->IsSMTP();
  12. $mail->SMTPSecure = "tls";
  13. $mail->port = "587";
  14. $mail->Host = 'smtp.gmail.com';
  15. $mail->SMTPAuth = true;
  16. $mail->Username = "myaddress@gmail.com";
  17. $mail->Password = "mypassword";
  18. $mail->From = "myaddress@gmail.com";
  19. $mail->FromName = "Alex";
  20. $mail->AddAddress("myaddress@gmail.com", "Alex");
  21. $mail->AddReplyTo("myaddress@gmail.com", "Information");
  22. $mail->WordWrap = 50;
  23. $mail->IsHTML(true);
  24. $mail->Subject = "Here is the subject";
  25. $mail->Body = "This is the HTML message body in bold!";
  26. $mail->AltBody = "This is the body in plain text for non-HTML mail clients";
  27. $mail->SMTPDebug = 2;
  28. if(!$mail->Send()){
  29. $er=$mail->ErrorInfo;
  30. $json = array("error" => "X", "errorMsg" => $er);
  31. }else{
  32. $json = array("error" => "X", "error" => "Message has been sent");
  33. }
  34. echo json_encode($json);
  35. return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement