Guest User

Untitled

a guest
Jun 25th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. <?php
  2.  
  3. require_once('phpmailer/class.phpmailer.php');
  4. include("phpmailer/class.smtp.php");
  5.  
  6. define('GUSER', 'testmein2017@gmail.com'); // GMail username
  7. define('GPWD', 'test@google'); // GMail password
  8.  
  9.  
  10. function smtpmailer($to, $from, $from_name, $subject, $body) {
  11. global $error;
  12. $mail = new PHPMailer(); // create a new object
  13. $mail->IsSMTP(); // enable SMTP
  14. $mail->SMTPDebug = 0; // debugging: 1 = errors and messages, 2 = messages only
  15. $mail->SMTPAuth = true; // authentication enabled
  16. $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
  17. $mail->Host = 'smtp.gmail.com';
  18. $mail->Port = 465;
  19. $mail->Username = GUSER;
  20. $mail->Password = GPWD;
  21. $mail->SetFrom($from, $from_name);
  22. $mail->Subject = $subject;
  23. $mail->Body = $body;
  24. $mail->AddAddress($to);
  25. $mail->IsHTML(true);
  26. if(!$mail->Send()) {
  27. $error = 'Mail error: '.$mail->ErrorInfo;
  28. return false;
  29. } else {
  30. $error = 'Message sent!';
  31. return true;
  32. }
  33. }
  34.  
  35.  
  36. ?>
Add Comment
Please, Sign In to add comment