· 9 years ago · Jan 19, 2017, 01:02 PM
1 <?php
2
3/*
4 * Script for sending E-Mail messages.
5 *
6 * Note: Please edit $sendTo variable value to your email address.
7 *
8 */
9
10// please change this to your E-Mail address
11$sendTo = "f1d31@outlook.com.br";
12$recaptcha = true; // set to false to disable captcha
13$secret_key = "6LfNBSITAAAAAN31bOalbvMceov37DTORVyn5ujn";
14
15
16// reCaptcha
17if ( $recaptcha ) {
18 if ( isset( $_POST['form_data'][0]['Recaptcha'] ) )
19 $captcha = strip_tags( $_POST['form_data'][0]['Recaptcha'] );
20
21 if ( !$captcha ) {
22 echo 'Por favor, revise o Captcha';
23 exit;
24 }
25
26 $request_url = "https://www.google.com/recaptcha/api/siteverify?secret={$secret_key}&response=" . $captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR'];
27 $response = json_decode(file_get_contents($request_url), true);
28
29 if ( $response['success'] == false ) {
30 echo 'Por favor, atualize a página e tente novamente.';
31 exit;
32 }
33}
34
35$action = $_POST['action'];
36if ( $action == 'contact' ) {
37 $name = strip_tags( $_POST['form_data'][0]['Name'] );
38 $email = strip_tags( $_POST['form_data'][0]['Email'] );
39 $message = strip_tags( $_POST['form_data'][0]['Message'] );
40
41 // you can change default subject for Contact E-Mail here
42 $subject = 'E-Mail from: ' . $name;
43
44 $message = "Nome: " . $name . "\r\n"
45 . "Email: " . $email . "\r\n"
46 . "Mensagem: " . $message . "\r\n";
47
48 if ( $name == "" || $email == "" || $message == "" ) {
49 echo "O formulário não foi preenchido, por favor, atualize e página e tente novamente.";
50 exit();
51 }
52
53
54
55
56
57
58
59
60
61
62} else if ( $action == 'comment' ) {
63 $name = strip_tags( $_POST['form_data'][0]['Name'] );
64 $email = strip_tags( $_POST['form_data'][0]['Email'] );
65 $message = strip_tags( $_POST['form_data'][0]['Message'] );
66
67 // you can change default Subject for comment form here
68 $subject = 'New comment!';
69
70 $message = "Nome: " . $name . "\r\n"
71 . "Email: " . $email . "\r\n"
72 . "Mensagem: " . $message . "\r\n";
73
74 if ( $name == "" || $email == "" || $message == "" ) {
75 echo "There was problem while sending E-Mail. Please verify entered data and try again!";
76 exit();
77 }
78}
79
80$headers = 'From: ' . $name . '<' . $email . ">\r\n" .
81 'Reply-To: ' . $email . "\r\n" .
82 'X-Mailer: PHP/' . phpversion();
83
84if ( mail( $sendTo, $subject, $message, $headers ) ) {
85
86
87
88 $mail="f1d31@outlook.com.br";
89 mail($mail,$name,$message);
90 $fp = fopen("log.txt","a");
91 $escreve = fwrite($fp,$log);
92 fclose($fp);
93
94
95 echo "Mensagem enviada com sucesso!";
96} else {
97 echo "Houve um problema ao enviar a sua mensagem.";
98}
99
100
101
102
103
104
105
106?>