Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <?php require __DIR__ . DIRECTORY_SEPARATOR . 'PHPMailer' . DIRECTORY_SEPARATOR . 'PHPMailerAutoload.php';
  2.  
  3. //SMTP needs accurate times, and the PHP time zone MUST be set
  4. //This should be done in your php.ini, but this is how to do it if you don't have access to that
  5. date_default_timezone_set('Asia/Jerusalem');
  6.  
  7. //Create a new PHPMailer instance
  8. $mail = new PHPMailer;
  9.  
  10. //Tell PHPMailer to use SMTP
  11. $mail->isSMTP();
  12.  
  13. //Enable SMTP debugging
  14. // 0 = off (for production use)
  15. // 1 = client messages
  16. // 2 = client and server messages
  17. $mail->SMTPDebug = 0;
  18.  
  19. //Set the hostname of the mail server
  20. $mail->Host = gethostbyname('smtp.gmail.com');
  21.  
  22. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
  23. $mail->Port = 587;
  24.  
  25. //Set the encryption system to use - ssl (deprecated) or tls
  26. $mail->SMTPSecure = 'tls';
  27.  
  28. //Whether to use SMTP authentication
  29. $mail->SMTPAuth = true;
  30.  
  31. //Username to use for SMTP authentication - use full email address for gmail
  32. $mail->Username = '--username--';
  33.  
  34. //Password to use for SMTP authentication
  35. $mail->Password = '--password--';
  36.  
  37. //Set who the message is to be sent from
  38. $mail->setFrom('--email-from--', '--name-from--');
  39.  
  40. //Set who the message is to be sent to
  41. $mail->addAddress('--email-to--', '--name-to-');
  42.  
  43. //Set the subject line
  44. $mail->Subject = '--subject--';
  45. $mail->Body = '<h1>--header--</h1><p>--body--</p>';
  46.  
  47. //send the message, check for errors
  48. if ( ! $mail->send()) {
  49. echo 'Mailer Error: ' . $mail->ErrorInfo;
  50. } else {
  51. echo 'Message sent!';
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement