Hello Friends, I need the help of a master, so that I can understand how the contact form works, the fields I have to fill and the libraries with direct calls by CDN, I’m using PHP, I can’t make it work by the form. estou usando bootstrap.
<?php /** * Requires the PHP Mail Form library * The PHP Mail Form library is available only in the pro version of the template * The library should be uploaded to: lib/php-mail-form/php-mail-form.php * For more info and help: https://templatemag.com/php-mail-form/ */ if( file_exists($php_mail_form_library = '../lib/php-mail-form/php-mail-form.php' )) { include( $php_mail_form_library ); } else { die( 'Unable to load the PHP Mail Form Library!'); } $contactform = new PHP_Mail_Form; $contactform->ajax = true; // Replace with your real receiving email address $contactform->to = '**contato@example.com**'; $contactform->from_name = $_POST['name']; $contactform->from_email = $_POST['email']; $contactform->subject = $_POST['subject']; $contactform->add_message( $_POST['name'], 'From'); $contactform->add_message( $_POST['email'], 'Email'); $contactform->add_message( $_POST['message'], 'Message', 10); echo $contactform->send(); ?>//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
<?php /** * PHP Mail Form * Version: 2.0 * Website: https://templatemag.com/php-mail-form/ * Copyright: TemplateMag.com */ class PHP_Mail_Form { public $to = false; public $from_name = false; public $from_email = false; public $subject = false; public $mailer = false; public $message = ''; public $content_type = 'text/html'; public $charset = 'UTF-8'; public $ajax = false; public $error_msg = array( 'invalid_to_email' => 'Email to: is empty or invalid!', 'invalid_from_name' => 'From Name is empty!', 'invalid_from_email' => 'Email from: is empty or invalid!', 'invalid_subject' => 'Subject is too short or empty!', 'invalid_mailer' => 'Mailer Email is empty or invalid!', 'short' => 'is too short or empty!', 'send_error' => 'Could not send mail! Please check your PHP mail configurations.', 'ajax_error' => 'Sorry, the request should be an Ajax POST', ); private $error = false; public function __construct() { $this->mailer = "formsubmit@" . @preg_replace('/^www\./','', $_SERVER['SERVER_NAME']); } public function add_message($content, $label = '', $length_check = false) { $message = filter_var($content, FILTER_SANITIZE_STRING) . ''; if( $length_check ) { if( strlen($message) < $length_check + 4 ) { $this->error .= $label . ' ' . $this->error_msg['short'] . '
'; return; } } $this->message .= !empty( $label ) ? '' . $label . ': ' . $message : $message; } public function send() { if( $this->ajax ) { if( !isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { return $this->error_msg['ajax_error']; } } $to = filter_var( $this->to, FILTER_VALIDATE_EMAIL); $from_name = filter_var( $this->from_name, FILTER_SANITIZE_STRING); $from_email = filter_var( $this->from_email, FILTER_VALIDATE_EMAIL); $subject = filter_var( $this->subject, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES); $mailer = filter_var( $this->mailer, FILTER_VALIDATE_EMAIL); $message = nl2br($this->message); if( ! $to || $to = 'contato@example.com') $this->error .= $this->error_msg['invalid_to_email'] . '
'; if( ! $from_name ) $this->error .= $this->error_msg['invalid_from_name'] . '
'; if( ! $from_email ) $this->error .= $this->error_msg['invalid_from_email'] . '
'; if( ! $subject ) $this->error .= $this->error_msg['invalid_subject'] . '
'; if( ! $mailer) $this->error .= $this->error_msg['invalid_mailer'] . '
'; if( $this->error ) { return $this->error; } $headers = 'From: ' . $from_name . ' <' . $mailer . '>' . PHP_EOL; $headers .= 'Reply-To: ' . $from_email . PHP_EOL; $headers .= 'MIME-Version: 1.0' . PHP_EOL; $headers .= 'Content-Type: ' . $this->content_type . '; charset=' . $this->charset . PHP_EOL; $headers .= 'X-Mailer: PHP/' . phpversion() . ' with PHP_Mail_Form'; $sendemail = mail($to, $subject, $message, $headers); if( $sendemail ) { return 'OK'; } else { return $this->error_msg['send_error']; } } } ?>
/////////////////////////////////////////////////////////////////////////////////
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
title
>My Page</
title
>
<
link
href
=
"/bootstrap/css/bootstrap-combined.min.css"
rel
=
"stylesheet"
>
<
link
href
=
"bootstrap/css/bootstrap-responsive.min.css"
rel
=
"stylesheet"
>
<
link
href
=
"css/my-stylesheet.css"
rel
=
"stylesheet"
>
</
head
>
<
body
>
<
div
class
=
"container"
>
</
div
>
<!-- /container -->
<
script
src
=
"js/jquery.min.js"
></
script
>
<
script
src
=
"bootstrap/js/bootstrap.min.js"
></
script
>
<
script
src
=
"js/my-javascript.js"
></
script
>
</
body
>
</
html
>
/////////////////////////////////////////////////////////////////////