PHP contact form workingtags/v1.0.0
@@ -1,5 +1,5 @@ | |||
{{ if .Site.Data.contact.enable }} | |||
{{"<!-- Srart Contact Us -->" | safeHTML}} | |||
{{"<!-- Start Contact Us -->" | safeHTML}} | |||
<section id="contact-us" class="contact-us section-bg"> | |||
<div class="container"> | |||
<div class="row"> | |||
@@ -27,14 +27,15 @@ | |||
{{"<!-- Contact Form -->" | safeHTML}} | |||
<div class="contact-form col-md-6 wow fadeInUp" data-wow-duration="500ms" data-wow-delay="300ms"> | |||
<form id="contact-form" method="post" action="sendmail.php" role="form"> | |||
<form id="contact-form" method="post" action="php/mailer.php" role="form"> | |||
<div class="form-group"> | |||
<input type="text" placeholder="Your Name" class="form-control" name="name" id="name"> | |||
</div> | |||
<div class="form-group"> | |||
<input type="email" placeholder="Your Email" class="form-control" name="email" id="email"> | |||
<input type="text" name="email" style="display: none;"> | |||
<input type="text" placeholder="Your Email" class="form-control" name="email_real" id="email"> | |||
</div> | |||
<div class="form-group"> | |||
@@ -73,4 +74,4 @@ | |||
</section> | |||
{{"<!-- /contact -->" | safeHTML}} | |||
{{ end }} | |||
{{ end }} |
@@ -2,8 +2,9 @@ | |||
{{"<!-- Welcome Slider-->" | safeHTML}} | |||
<section class="hero-area" style='background-image: url("{{ .Site.Params.banner.bgImage | absURL }}");'> | |||
<div class="block"> | |||
<div class="video-button"> | |||
{{with .Site.Params.banner.icon}} <i class="{{ . }}"></i> {{ end }} | |||
<div class="logo"> | |||
<p><img class="logo" src="images/logo.png"></p> | |||
{{with .Site.Params.banner.icon}} <i class="{{ . }}"></i> {{ end }} video-button | |||
</div> | |||
{{with .Site.Params.banner.heading}} <h1>{{ . }}</h1>{{ end }} | |||
{{with .Site.Params.banner.content}} <p>{{ . }}</p> {{ end }} |
@@ -0,0 +1,77 @@ | |||
<?php | |||
// you need to replace your SMTP login details here | |||
// this script is working for sending mail but not making a proper js call back yet | |||
use PHPMailer\PHPMailer\PHPMailer; | |||
use PHPMailer\PHPMailer\Exception; | |||
require 'phpmailer/Exception.php'; | |||
require 'phpmailer/PHPMailer.php'; | |||
require 'phpmailer/SMTP.php'; | |||
//$mail->SMTPDebug = 2; | |||
// this should catch a lot of spam bots | |||
$honeypot = trim($_POST["email"]); | |||
if(!empty($honeypot)) { | |||
echo "BAD ROBOT!"; | |||
exit; | |||
} | |||
$msg = ''; | |||
//Don't run this unless we're handling a form submission | |||
if (array_key_exists('email', $_POST)) { | |||
date_default_timezone_set('Etc/UTC'); | |||
$mail = new PHPMailer; | |||
//Tell PHPMailer to use SMTP - requires a local mail server | |||
//Faster and safer than using mail() | |||
$mail->isSMTP(); // Set mailer to use SMTP | |||
$mail->Host = 'smtp.server.net'; // Specify main and backup SMTP servers | |||
$mail->SMTPAuth = true; // Enable SMTP authentication | |||
$mail->Username = 'mailer@server.net'; // SMTP username | |||
$mail->Password = 'mailerPASSWord'; // SMTP password | |||
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted | |||
$mail->Port = 25; // TCP port to connect to | |||
//Use a fixed address in your own domain as the from address | |||
//**DO NOT** use the submitter's address here as it will be forgery | |||
//and will cause your messages to fail SPF checks | |||
$mail->setFrom('sender@server.net', 'Your Name'); | |||
//Send the message to yourself, or whoever should receive contact for submissions | |||
$mail->addAddress('testsendmail@greenant.net', 'Your Name'); | |||
//Put the submitter's address in a reply-to header | |||
//This will fail if the address provided is invalid, | |||
//in which case we should ignore the whole request | |||
if ($mail->addReplyTo($_POST['email_real'], $_POST['name'])) { | |||
$mail->Subject = 'PHPMailer contact form'; | |||
//Keep it simple - don't use HTML | |||
$mail->isHTML(false); | |||
//Build a simple message body | |||
$mail->Body = <<<EOT | |||
Email: {$_POST['email_real']} | |||
Name: {$_POST['name']} | |||
Message: {$_POST['message']} | |||
EOT; | |||
//Send the message, check for errors | |||
if (!$mail->send()) { | |||
//The reason for failing to send will be in $mail->ErrorInfo | |||
//but you shouldn't display errors to users - process the error, log it on your server. | |||
$msg = 'Sorry, something went wrong. Please try again later.'; | |||
} else { | |||
$msg = 'sent'; | |||
} | |||
} else { | |||
$msg = 'Invalid email address, message ignored.'; | |||
} | |||
echo $msg; | |||
return $msg; | |||
//exit; | |||
} | |||
?> |
@@ -0,0 +1,40 @@ | |||
<?php | |||
/** | |||
* PHPMailer Exception class. | |||
* PHP Version 5.5. | |||
* | |||
* @see https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project | |||
* | |||
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk> | |||
* @author Jim Jagielski (jimjag) <jimjag@gmail.com> | |||
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net> | |||
* @author Brent R. Matzelle (original founder) | |||
* @copyright 2012 - 2017 Marcus Bointon | |||
* @copyright 2010 - 2012 Jim Jagielski | |||
* @copyright 2004 - 2009 Andy Prevost | |||
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License | |||
* @note This program is distributed in the hope that it will be useful - WITHOUT | |||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |||
* FITNESS FOR A PARTICULAR PURPOSE. | |||
*/ | |||
namespace PHPMailer\PHPMailer; | |||
/** | |||
* PHPMailer exception handler. | |||
* | |||
* @author Marcus Bointon <phpmailer@synchromedia.co.uk> | |||
*/ | |||
class Exception extends \Exception | |||
{ | |||
/** | |||
* Prettify error message output. | |||
* | |||
* @return string | |||
*/ | |||
public function errorMessage() | |||
{ | |||
return '<strong>' . htmlspecialchars($this->getMessage()) . "</strong><br />\n"; | |||
} | |||
} | |||