Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2. require_once('class.phpmailer.php');
  3.  
  4. $mail = new PHPMailer(); // create a new object
  5. $mail->IsSMTP(); // enable SMTP
  6. $mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
  7. $mail->SMTPAuth = true; // authentication enabled
  8. $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
  9. $mail->Host = "smtp.gmail.com";
  10. $mail->Port = 465; // or 587
  11. $mail->IsHTML(true);
  12. $mail->Username = "example@gmail.com";
  13. $mail->Password = "********";
  14. $mail->SetFrom("example@gmail.com");
  15. $mail->Subject = "Test";
  16. $mail->Body = "hello";
  17. $mail->AddAddress("to.email@gmail.com");
  18.  
  19. if(!$mail->Send()) {
  20. echo "Mailer Error: " . $mail->ErrorInfo;
  21. } else {
  22. echo "Message has been sent";
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement