Guest User

Untitled

a guest
Jan 15th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. <?php
  2. $msg = "";
  3. use PHPMailerPHPMailerPHPMailer;
  4. include_once "PHPMailer/PHPMailer.php";
  5. include_once "PHPMailer/Exception.php";
  6. include_once "PHPMailer/SMTP.php";
  7. include_once "PHPMailer/OAuth.php";
  8. //include_once "PHPMailer/POP3.php";
  9.  
  10. if (isset($_POST['submit'])) {
  11. $subject = $_POST['subject'];
  12. $email = $_POST['email'];
  13. $message = $_POST['message'];
  14.  
  15. if (isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != "") {
  16. $file = "attachment/" . basename($_FILES['attachment']['name']);
  17. move_uploaded_file($_FILES['attachment']['tmp_name'], $file);
  18. } else
  19. $file = "";
  20.  
  21. //echo $file;
  22.  
  23. $mail = new PHPMailer();
  24.  
  25. //if we want to send via SMTP
  26. $mail->Host = "localhost";
  27. $mail->isSMTP();
  28. $mail->SMTPAuth = true;
  29. $mail->Username = "support@webeon.uz";
  30. $mail->Password = "87QgzNps!_tP";
  31. $mail->SMTPSecure = "tls"; //TLS
  32. $mail->Port = 587; //465 or 587
  33. $mail->SMTPDebug = 3;
  34.  
  35.  
  36. $mail->addAddress('bakhrom.akbarov@gmail.com');
  37. $mail->setFrom($email);
  38. $mail->Subject = $subject;
  39. $mail->isHTML(true);
  40. $mail->Body = $message;
  41. $mail->addAttachment($file);
  42.  
  43. if ($mail->send())
  44. $msg = "Your email has been sent, thank you!";
  45. else
  46. //$msg = "Please try agian!";
  47. echo $mail->ErrorInfo;
  48. }
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. $ch = curl_init();
  56. curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
  57. curl_setopt($ch, CURLOPT_HEADER, 0);
  58. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  59. curl_setopt($ch, CURLOPT_POST, 1);
  60. curl_setopt($ch, CURLOPT_POSTFIELDS, [
  61. $privatekey=>'6LfZ7IkUAAAAAM5OMzT4jFHijzIeuomW4Esb6tgI',
  62. 'secret' => $privatekey,
  63. 'response' => $_POST['g-recaptcha-response'],
  64. 'remoteip' => $_SERVER['REMOTE_ADDR']
  65. ]);
  66.  
  67. $resp = json_decode(curl_exec($ch));
  68. curl_close($ch);
  69.  
  70. if ($resp->success) {
  71. // Success
  72. } else {
  73. // failure
  74. }
  75. ?>
  76.  
  77. <!DOCTYPE html>
  78. <html lang="en">
  79. <head>
  80. <meta charset="UTF-8">
  81. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  82. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  83. <title>Document</title>
  84.  
  85. <!-- Latest compiled and minified CSS -->
  86. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  87.  
  88. <!-- Optional theme -->
  89. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
  90.  
  91. <!-- Latest compiled and minified JavaScript -->
  92. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  93. <script src='https://www.google.com/recaptcha/api.js?render=6LdilIkUAAAAAHm8k_SW8ZlvqdcRLVMdW0-OJFDI'></script>
  94. </head>
  95. <body>
  96. <div class="container" style="margin-top: 100px;">
  97. <div class="row justify-content-center">
  98. <div class="col-md-6 col-md-offset-3" align="center">
  99. <img src="images/webeon1.png" alt="" style="width: 100px;"><br><br>
  100.  
  101. <?php if ($msg != "") echo "$msg<br><br>;" ?>
  102.  
  103. <form method="post" action="sendemail.php" enctype="multipart/form-data">
  104. <input class="form-control" name="subject" placeholder="Subject..."><br>
  105. <input class="form-control" name="email" type="email" placeholder="Email..."><br>
  106. <textarea class="form-control" placeholder="Message..." name="message" id="" style="width: 100%; left: 0; margin-bottom: 10px;"></textarea><br>
  107. <div class="g-recaptcha" data-sitekey="6LfZ7IkUAAAAALHvA1xQb4bPeACajNEKpkXiysw5"></div>
  108. <input class="btn btn-primary" name="submit" type="submit" value="Send Email">
  109. </form>
  110. </div>
  111. </div>
  112. </div>
  113. <script src='https://www.google.com/recaptcha/api.js'></script>
  114. </body>
  115. </html>
Add Comment
Please, Sign In to add comment