Guest User

Untitled

a guest
May 2nd, 2018
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2. use PHPMailerPHPMailer;
  3. use PHPMailerException;
  4.  
  5. require 'PHPMailer/PHPMailerAutoload.php';
  6.  
  7. $mail = new PHPMailer(true);
  8. try {
  9. //Server settings
  10. $mail->SMTPDebug = 4;
  11. $mail->isSMTP();
  12. $mail->Host = 'smtp.gmail.com';
  13. $mail->SMTPAuth = true;
  14. $mail->Username = 'thisismy@gmail.com';
  15. $mail->Password = 'xxxxxxxx';
  16. $mail->SMTPSecure = 'tls';
  17. $mail->Port = 587;
  18.  
  19.  
  20.  
  21. //Recipients
  22. $mail->setFrom('from@example.com', 'Mailer');
  23. $mail->addAddress('receiver@gmail.com');
  24.  
  25.  
  26.  
  27. //Content
  28. $mail->isHTML(true);
  29. $mail->Subject = 'Here is the subject';
  30. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  31. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  32.  
  33. $mail->send();
  34. echo 'Message has been sent';
  35. } catch (Exception $e) {
  36. echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  37. }
  38. ?>
Add Comment
Please, Sign In to add comment