Advertisement
Guest User

Untitled

a guest
Mar 1st, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. require '/home/schoswiy/public_html/assets/PHPMailer-master/src/PHPMailer.php';
  2. require '/home/schoswiy/public_html/assets/PHPMailer-master/src/SMTP.php';
  3. require '/home/schoswiy/public_html/assets/PHPMailer-master/src/Exception.php';
  4.  
  5.  
  6.  
  7. set_time_limit(0);
  8.  
  9.  
  10.  
  11. if(isset($_POST['send_message'])){
  12. $name = trim($_POST['name']);
  13. $subject = trim($_POST['subject']);
  14. $email = trim($_POST['email']);
  15. $message = trim($_POST['message']);
  16.  
  17. $mail = new PHPMailerPHPMailerPHPMailer(true);
  18. $mail->isSMTP();
  19.  
  20. $mail->Host = 'smtp.gmail.com';
  21. $mail->SMTPOptions = array(
  22. 'ssl' => array(
  23. 'verify_peer' => false,
  24. 'verify_peer_name' => false,
  25. 'allow_self_signed' => true
  26. )
  27. );
  28.  
  29. $mail->SMTPAuth = true;
  30.  
  31. $mail->Port= 465;
  32. $mail->SMTPDebug = 4;
  33.  
  34. $mail->Username ='myemail@gmail.com';
  35. $mail->Password = 'pass';
  36.  
  37. $mail->SMTPSecure = 'ssl';
  38.  
  39.  
  40. $mail->setFrom('myemail@gmail.com', 'xyz');
  41. $mail->addReplyTo($email, $name);
  42. $mail->addAddress('myemail@gmail.com');
  43.  
  44.  
  45.  
  46. $mail->Subject = $subject;
  47.  
  48.  
  49. $mail->Body = $message;
  50.  
  51. if($mail->send()){
  52. $_SESSION['msg'] = 'Message Send Successfully';
  53. header("location:contact-us.php");
  54. echo "messsage Send";
  55. }
  56. else {
  57. echo "<script type='text/javascript'> alert('Failed to send')</script>";
  58. }
  59.  
  60. }
  61.  
  62.  
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement