Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $msg = "";
- use PHPMailerPHPMailerPHPMailer;
- include_once "PHPMailer/PHPMailer.php";
- include_once "PHPMailer/Exception.php";
- include_once "PHPMailer/SMTP.php";
- include_once "PHPMailer/OAuth.php";
- //include_once "PHPMailer/POP3.php";
- if (isset($_POST['submit'])) {
- $subject = $_POST['subject'];
- $email = $_POST['email'];
- $message = $_POST['message'];
- if (isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != "") {
- $file = "attachment/" . basename($_FILES['attachment']['name']);
- move_uploaded_file($_FILES['attachment']['tmp_name'], $file);
- } else
- $file = "";
- //echo $file;
- $mail = new PHPMailer();
- //if we want to send via SMTP
- $mail->Host = "localhost";
- $mail->isSMTP();
- $mail->SMTPAuth = true;
- $mail->Username = "support@webeon.uz";
- $mail->Password = "87QgzNps!_tP";
- $mail->SMTPSecure = "tls"; //TLS
- $mail->Port = 587; //465 or 587
- $mail->SMTPDebug = 3;
- $mail->addAddress('bakhrom.akbarov@gmail.com');
- $mail->setFrom($email);
- $mail->Subject = $subject;
- $mail->isHTML(true);
- $mail->Body = $message;
- $mail->addAttachment($file);
- if ($mail->send())
- $msg = "Your email has been sent, thank you!";
- else
- //$msg = "Please try agian!";
- echo $mail->ErrorInfo;
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify");
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, [
- $privatekey=>'6LfZ7IkUAAAAAM5OMzT4jFHijzIeuomW4Esb6tgI',
- 'secret' => $privatekey,
- 'response' => $_POST['g-recaptcha-response'],
- 'remoteip' => $_SERVER['REMOTE_ADDR']
- ]);
- $resp = json_decode(curl_exec($ch));
- curl_close($ch);
- if ($resp->success) {
- // Success
- } else {
- // failure
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
- <!-- Latest compiled and minified CSS -->
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
- <!-- Optional theme -->
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
- <!-- Latest compiled and minified JavaScript -->
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
- <script src='https://www.google.com/recaptcha/api.js?render=6LdilIkUAAAAAHm8k_SW8ZlvqdcRLVMdW0-OJFDI'></script>
- </head>
- <body>
- <div class="container" style="margin-top: 100px;">
- <div class="row justify-content-center">
- <div class="col-md-6 col-md-offset-3" align="center">
- <img src="images/webeon1.png" alt="" style="width: 100px;"><br><br>
- <?php if ($msg != "") echo "$msg<br><br>;" ?>
- <form method="post" action="sendemail.php" enctype="multipart/form-data">
- <input class="form-control" name="subject" placeholder="Subject..."><br>
- <input class="form-control" name="email" type="email" placeholder="Email..."><br>
- <textarea class="form-control" placeholder="Message..." name="message" id="" style="width: 100%; left: 0; margin-bottom: 10px;"></textarea><br>
- <div class="g-recaptcha" data-sitekey="6LfZ7IkUAAAAALHvA1xQb4bPeACajNEKpkXiysw5"></div>
- <input class="btn btn-primary" name="submit" type="submit" value="Send Email">
- </form>
- </div>
- </div>
- </div>
- <script src='https://www.google.com/recaptcha/api.js'></script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment