Guest User

Untitled

a guest
Feb 14th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. use PHPMailerPHPMailerPHPMailer;
  2. use PHPMailerPHPMailerException;
  3.  
  4. require 'vendor/autoload.php';
  5.  
  6. $mail = new PHPMailer(true);
  7.  
  8. //$mail->SMTPDebug = 2;
  9. //$mail->isSMTP();
  10. $mail->Host = 'smtp.gmail.com';
  11. $mail->SMTPAuth = true;
  12. $mail->Username = 'myemail@gmail.com';
  13. $mail->Password = 'mypassword';
  14. $mail->SMTPSecure = 'ssl';
  15. $mail->Port = 587;
  16. $mail->setFrom('myemail@gmail.com', 'Mailer');
  17. $mail->addAddress('example@gmail.com', 'Joe User');
  18.  
  19. $mail->isHTML(true);
  20. $mail->Subject = 'Here is the subject';
  21. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  22.  
  23. if($mail->send()){
  24. echo 'Message has been sent successfully';
  25. } else {
  26. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  27. }
Add Comment
Please, Sign In to add comment