Advertisement
Guest User

Untitled

a guest
Aug 1st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. require 'class.phpmailer.php'; // path to the PHPMailer class
  2. require 'class.smtp.php';
  3.  
  4. $mail = new PHPMailer();
  5.  
  6.  
  7. $mail->IsSMTP(); // telling the class to use SMTP
  8. $mail->SMTPDebug = 2;
  9. $mail->Mailer = "smtp";
  10. $mail->Host = "ssl://smtp.gmail.com";
  11. $mail->Port = 587;
  12. $mail->SMTPAuth = true; // turn on SMTP authentication
  13. $mail->Username = "myemail@gmail.com"; // SMTP username
  14. $mail->Password = "mypasswword"; // SMTP password
  15. $Mail->Priority = 1;
  16.  
  17. $mail->AddAddress("myemail@gmail.com","Name");
  18. $mail->SetFrom($visitor_email, $name);
  19. $mail->AddReplyTo($visitor_email,$name);
  20.  
  21. $mail->Subject = "Message from Contact form";
  22. $mail->Body = $user_message;
  23. $mail->WordWrap = 50;
  24.  
  25. if(!$mail->Send()) {
  26. echo 'Message was not sent.';
  27. echo 'Mailer error: ' . $mail->ErrorInfo;
  28. } else {
  29. echo 'Message has been sent.';
  30. }
  31.  
  32. $mail->IsSMTP();
  33.  
  34. //Set the hostname of the mail server
  35. $mail->Host = 'smtp.gmail.com';
  36.  
  37. //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission 465 ssl
  38. $mail->Port = 465;
  39.  
  40. //Set the encryption system to use - ssl (deprecated) or tls
  41. $mail->SMTPSecure = 'ssl';
  42.  
  43. + $mail->SMTPSecure = 'tls';
  44.  
  45. - $mail->Host = "ssl://smtp.gmail.com";
  46. + $mail->Host = "smtp.gmail.com";
  47.  
  48. ###############################################################################
  49. # SECTION:SMTP Settings
  50. ###############################################################################
  51. # Block outgoing SMTP except for root, exim and mailman (forces scripts/users
  52. # to use the exim/sendmail binary instead of sockets access). This replaces the
  53. # protection as WHM > Tweak Settings > SMTP Tweaks
  54. #
  55. # This option uses the iptables ipt_owner/xt_owner module and must be loaded
  56. # for it to work. It may not be available on some VPS platforms
  57. #
  58. # Note: Run /etc/csf/csftest.pl to check whether this option will function on
  59. # this server
  60. # SMTP_BLOCK = "1" --> this will cause phpmailer Connection timed out (110)
  61. SMTP_BLOCK = "0"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement