Guest User

Untitled

a guest
Oct 16th, 2016
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2. require 'phpmailer/class.phpmailer.php';
  3.  
  4. $mail = new PHPMailer;
  5.  
  6. $mail->IsSMTP(); // Set mailer to use SMTP
  7. $mail->Host = 'smtp.gmail.com'; // Specify main and backup server
  8. $mail->Port = 465; // Set the SMTP port
  9. $mail->SMTPAuth = true; // Enable SMTP authentication
  10. $mail->Username = 'USERNAME'; // SMTP username
  11. $mail->Password = 'APIKEY'; // SMTP password
  12. $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
  13.  
  14. $mail->From = 'from@example.com';
  15. $mail->FromName = 'Your From name';
  16. $mail->AddAddress('josh@example.net', 'Josh Adams'); // Add a recipient
  17. $mail->AddAddress('ellen@example.com'); // Name is optional
  18.  
  19. $mail->IsHTML(true); // Set email format to HTML
  20.  
  21. $mail->Subject = 'Here is the subject';
  22. $mail->Body = 'This is the HTML message body <strong>in bold!</strong>';
  23. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  24.  
  25. if(!$mail->Send()) {
  26. echo 'Message could not be sent.';
  27. echo 'Mailer Error: ' . $mail->ErrorInfo;
  28. exit;
  29. }
  30.  
  31. echo 'Message has been sent';
Add Comment
Please, Sign In to add comment