Advertisement
kunkin1

send-mail-4

Jan 2nd, 2017
2,982
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.18 KB | None | 0 0
  1. <?php
  2.  
  3. require_once "vendor/autoload.php";
  4.  
  5. $mail = new PHPMailer;
  6.  
  7. //Enable SMTP debugging.
  8. $mail->SMTPDebug = 3;                              
  9. //Set PHPMailer to use SMTP.
  10. $mail->isSMTP();            
  11. //Set SMTP host name                          
  12. $mail->Host = "smtp.gmail.com";
  13. //Set this to true if SMTP host requires authentication to send email
  14. $mail->SMTPAuth = true;                          
  15. //Provide username and password    
  16. $mail->Username = "name@gmail.com";                
  17. $mail->Password = "super_secret_password";                          
  18. //If SMTP requires TLS encryption then set it
  19. $mail->SMTPSecure = "tls";                          
  20. //Set TCP port to connect to
  21. $mail->Port = 587;                                  
  22.  
  23. $mail->From = "name@gmail.com";
  24. $mail->FromName = "Full Name";
  25.  
  26. $mail->addAddress("name@example.com", "Recepient Name");
  27.  
  28. $mail->isHTML(true);
  29.  
  30. $mail->Subject = "Subject Text";
  31. $mail->Body = "<i>Mail body in HTML</i>";
  32. $mail->AltBody = "This is the plain text version of the email content";
  33.  
  34. if(!$mail->send())
  35. {
  36.     echo "Mailer Error: " . $mail->ErrorInfo;
  37. }
  38. else
  39. {
  40.     echo "Message has been sent successfully";
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement