Advertisement
Guest User

Untitled

a guest
Nov 28th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <?php
  2. date_default_timezone_set('Etc/UTC');
  3. require_once('PHPMailer/PHPMailerAutoload.php');
  4.  
  5. $mail = new PHPMailer(); // create a new object
  6. $mail->IsSMTP(); // enable SMTP
  7. $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
  8. $mail->SMTPAuth = true; // authentication enabled
  9. $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
  10. $mail->Host = "smtp.gmail.com";
  11. $mail->Port = 465; // or 587
  12. $mail->IsHTML(true);
  13. $mail->Username = "user@gmail.com";
  14. $mail->Password = "pass";
  15. $mail->SetFrom("user@gmail.com");
  16. $mail->Subject = "Test";
  17. $mail->Body = "hello";
  18. $mail->AddAddress("from@gmail.com");
  19. $mail->SMTPOptions = array (
  20. 'ssl' => array (
  21. 'verify_peer' => false,
  22. 'verify_peer_name' => false,
  23. 'allow_self_signed' => true
  24. )
  25. );
  26. if(!$mail->Send()) {
  27. echo "Mailer Error: " . $mail->ErrorInfo;
  28. } else {
  29. echo "Message has been sent";
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement