· 7 years ago · Jul 06, 2018, 08:12 PM
1<?php
2date_default_timezone_set('Etc/UTC');
3require_once 'autoload.php';
4 ini_set('display_errors',1); error_reporting(E_ALL);
5 if(isset($_POST['submit'])){
6 $userIP = $_SERVER["REMOTE_ADDR"];
7 $recaptchaResponse = $_POST['g-recaptcha-response'];
8 $secretKey = '6LdvpmIUAAAAAOOVJDAZ3ZrjTljB1QeZ-wyoOoBD';
9 $request = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secretKey}&response={$recaptchaResponse}&remoteip={$userIP}");
10 if(!strstr($request, "true")){
11 echo '<div class="alert alert-danger" role="alert"><strong>Error!</strong>There was a problem with the Captcha, you lied to us! you are a robot! or you just didnt click it :)</div>';
12 }
13 else{
14 if(isset($_POST['submit']))
15 {
16 $message=
17 'name: '.$_POST['name'].'<br />
18 email: '.$_POST['email'].'<br />
19 mess: '.$_POST['message'].'
20 ';
21 require "PHPMailer-master/class.phpmailer.php";
22 $mail = new PHPMailer();
23 $mail->IsSMTP();
24 $mail->SMTPAuth = true;
25 $mail->SMTPSecure = "tls";
26 $mail->Host = "mail25.mydevil.net";
27 $mail->Port = 465;
28 $mail->Encoding = '7bit';
29 // Authentication
30 $mail->Username = 'jakubwolowski@webdeveloper.pl';
31 $mail->Password = 'lCjwxXR2ybun7IsxEU';
32 // Compose
33 $mail->SetFrom($_POST['email'], $_POST['name']);
34 $mail->AddReplyTo($_POST['email'], $_POST['name']);
35 $mail->WordWrap = 50;
36 $mail->MsgHTML($message);
37 // Send To
38 $mail->AddAddress('mp@metalprodukt.eu');
39 $result = $mail->Send();
40 $message = $result ? '<div class="alert alert-success" role="alert"><strong>Success!</strong>Message Sent Successfully!</div>' : '<div class="alert alert-danger" role="alert"><strong>Error!</strong>There was a problem delivering the message.</div>';
41 unset($mail);
42 }
43 }
44 }