Guest User

Untitled

a guest
Dec 12th, 2017
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL);
  3. use PHPMailer\PHPMailer\PHPMailer;
  4. use PHPMailer\PHPMailer\Exception;
  5.  
  6. require_once('../vendor/autoload.php');
  7. $mail = new PHPMailer(); // create a new object
  8. $mail->IsSMTP(); // enable SMTP
  9. $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
  10. $mail->SMTPAuth = true; // authentication enabled
  11. $mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for Gmail
  12. $mail->Host = "smtp.gmail.com";
  13. $mail->Port = 587; // or 465 ssl
  14. $mail->IsHTML(true);
  15. $mail->Username = "username@gmail.com";
  16. $mail->Password = "password";
  17. $mail->SetFrom("example@gmail.com");
  18. $mail->Subject = "Test";
  19. $mail->Body = "hello";
  20. $mail->AddAddress("toAddress");
  21.  
  22. //Added to example code to make it work from Azure
  23. $mail->SMTPOptions = array(
  24. 'ssl' => array(
  25. 'verify_peer' => false,
  26. 'verify_peer_name' => false,
  27. 'allow_self_signed' => true
  28. )
  29. );
  30.  
  31.  
  32. if(!$mail->Send()) {
  33. echo "Mailer Error: " . $mail->ErrorInfo;
  34. } else {
  35. echo "Message has been sent";
  36. }
  37. ?>
Add Comment
Please, Sign In to add comment