Advertisement
dulara1994

Untitled

Jan 10th, 2018
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <?php
  2. date_default_timezone_set('America/Los_Angeles');
  3.  
  4. use PHPMailer\PHPMailer\PHPMailer;
  5. use PHPMailer\PHPMailer\SMTP;
  6. use PHPMailer\PHPMailer\Exception;
  7.  
  8.  
  9. include_once("src/PHPMailer.php");
  10. include_once("src/SMTP.php");
  11. include_once("src/Exception.php");
  12.  
  13.  
  14. $mail = new PHPMailer;
  15. $mail->SMTPDebug = 1;
  16. $mail->Port = 587;
  17.  
  18. $mail->IsSMTP();
  19. $mail->Host = 'mail.mymail.com';
  20. $mail->SMTPAuth = true;
  21. $mail->Username = 'admin@mymail.com';
  22. $mail->Password = 'Pa55word';
  23. $mail->SMTPSecure = ''; // tried ssl and tls, with same result
  24.  
  25. $mail->ClearAddresses();
  26. $mail->AddAddress('testmail@gmail.com', 'tester1');
  27. $mail->From = "admin@mymail.com";
  28. $mail->FromName = "Username";
  29. $mail->Subject = 'Hi there';
  30. $mail->Body = "This is a test message";
  31.  
  32. if ($mail->Send()) {
  33.     echo "Message sent!\n";
  34. }
  35. else {
  36.     echo "Message failed!\n";
  37.     print_r($mail->ErrorInfo);
  38. }
  39.  
  40. exit();
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement