Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- require 'vendor/autoload.php';
- $name = $_POST['name'];
- $priority = $_POST['priority'];
- $message = $_POST['message'];
- $email = $_POST['email'];
- $product = $_POST['product'];
- $type = $_POST['type'];
- $phone = $_POST['phone'];
- if ($type == '') {
- $type = 'N/A';
- }
- $mail = new PHPMailer;
- $mail->isSMTP();
- //Enable SMTP debugging
- $mail->SMTPDebug = 2;
- //Set the hostname of the mail server
- $mail->Host = 'smtp.gmail.com';
- //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
- $mail->Port = 587;
- //Set the encryption system to use - ssl (deprecated) or tls
- $mail->SMTPSecure = 'tls';
- //Whether to use SMTP authentication
- $mail->SMTPAuth = true;
- //Username to use for SMTP authentication - use full email address for gmail
- $mail->Username = "vwardak@gmail.com";
- //Password to use for SMTP authentication
- $mail->Password = "REMOVED";
- //Set who the message is to be sent from
- $mail->setFrom($email, $name);
- //Set who the message is to be sent to
- $mail->addAddress('vwardak@gmail.com', 'HBPlug');
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Contact Form - '.$project_name;
- $mail->Body = '
- <table border="0" cellpadding="0" cellspacing="0" width="100%" style="
- max-width: 35%;
- margin: 0 auto;
- background: white;
- text-align:center;
- ">
- <tr>
- <td>
- <table border="0" cellpadding="0" cellspacing="0" width="100%" style="
- padding: 25px;
- background: #fff;
- border: 1px solid #ddd;
- border-top: none !important;
- text-align: center;">
- <tr>
- <td>
- <table border="0" cellpadding="0" cellspacing="0" width="100%">
- <tr>
- <td style="
- font-size: 18px;
- padding-bottom: 5px;
- ">
- Customer Name
- </td>
- </tr>
- <tr>
- <td style="
- font-size: 15px;
- color: #adadad;
- ">
- '. $name .'
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td>
- <table border="0" cellpadding="0" cellspacing="0" width="100%" style="
- padding: 25px;
- background: #fff;
- border: 1px solid #ddd;
- border-top: none !important;
- text-align: center;">
- <tr>
- <td>
- <table border="0" cellpadding="0" cellspacing="0" width="100%">
- <tr>
- <td style="
- font-size: 18px;
- padding-bottom: 5px;
- ">
- Phone Number
- </td>
- </tr>
- <tr>
- <td style="
- font-size: 15px;
- color: #adadad;
- ">
- '. $phone .'
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td>
- <table border="0" cellpadding="0" cellspacing="0" width="100%" style="
- padding: 25px;
- background: #fff;
- border: 1px solid #ddd;
- border-top: none !important;
- text-align: center;">
- <tr>
- <td>
- <table border="0" cellpadding="0" cellspacing="0" width="100%">
- <tr>
- <td style="
- font-size: 18px;
- padding-bottom: 5px;
- ">
- Product
- </td>
- </tr>
- <tr>
- <td style="
- font-size: 15px;
- color: #adadad;
- ">
- '. $product .' / '. $type .'
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <td>
- <table border="0" cellpadding="0" cellspacing="0" width="100%" style="
- padding: 25px;
- background: #fff;
- border: 1px solid #ddd;
- border-top: none !important;
- text-align: center;">
- <tr>
- <td>
- <table border="0" cellpadding="0" cellspacing="0" width="100%">
- <tr>
- <td style="
- font-size: 18px;
- padding-bottom: 5px;
- ">
- Message
- </td>
- </tr>
- <tr>
- <td style="
- font-size: 15px;
- color: #adadad;
- ">
- '. $message .'
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- ';
- $response = $_POST["g-recaptcha-response"];
- $url = 'https://www.google.com/recaptcha/api/siteverify';
- $data = array(
- 'secret' => '6LccjzIUAAAAAE-nT0zWpiagBMswsi2VzK5PdKwd',
- 'response' => $_POST["g-recaptcha-response"]
- );
- $options = array(
- 'http' => array (
- 'method' => 'POST',
- 'content' => http_build_query($data)
- )
- );
- $context = stream_context_create($options);
- $verify = file_get_contents($url, false, $context);
- $captcha_success=json_decode($verify);
- if ($captcha_success->success==false) {
- header("Location: /");
- } else if ($captcha_success->success==true) {
- if (!$mail->send()) {
- // Error
- header("Location: /");
- } else {
- $mail->send();
- header("Location: /");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement