Guest User

Untitled

a guest
Dec 25th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2.  
  3. use PHPMailerPHPMailerPHPMailer;
  4. use PHPMailerPHPMailerException;
  5.  
  6. require '../PHPMailer/src/PHPMailer.php';
  7.  
  8.  
  9. $mail = new PHPMailer(); // create a new object
  10. $mail->IsSMTP(); // enable SMTP
  11. $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
  12. $mail->SMTPAuth = true; // authentication enabled
  13. $mail->SMTPSecure = 'tls'; // secure transfer enabled REQUIRED for GMail
  14. $mail->Host = "smtp.gmail.com";
  15.  
  16. $mail->Port = 587; // or 587 or 465
  17. $mail->IsHTML(true);
  18. $mail->Username = "myaccountname";
  19. $mail->Password = "mypassword";
  20. $mail->setFrom('fromemailid', 'from name');
  21. $mail->Subject = 'Test Mail';
  22. $mail->Body = 'Test mail body';
  23. $mail->AddAddress("someone@gmail.com");
  24.  
  25. if (!$mail->send())
  26.  
  27. {echo "Mailer Error: " . $mail->ErrorInfo;
  28. return false;
  29. } else {
  30. return true;
  31. }
  32.  
  33. ?>
Add Comment
Please, Sign In to add comment