SHARE
TWEET

Untitled

a guest Apr 21st, 2018 246 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top