Contact Form not sending Email but success page appears
Please be nice, I am new to coding and this is my first time posting. I am just stuck and thought I would try this out.
I have this contact form and I cannot figure out why it will not send me the email with the filled in contact information. I did this in a prior class and got it to work but it is not working for this page. I bold the 3 page names index.php, contact.html.php and success.html.php and posted code beneath, I did not post the entire file, I believe this is the relevant information.
Here is the link to my contact form that is on my domain.
THANK YOU!
Contact Form [Moderator note: removed link]
index.php
) AND empty($_POST['honeypot'>)) {
date_default_timezone_set('Etc/UTC');
$myname = $_POST['myname'>;
$myemail = $_POST['myemail'>;
$myrole = $_POST['myrole'>;
$myquestioncomment = $_POST['myquestioncomment'>;
$honeypot = $_POST['honeypot'>;
try {
$sql = 'INSERT INTO contact SET
myname = :myname,
myemail = :myemail,
myrole = :myrole,
myquestioncomment = :myquestioncomment';
$s = $pdo->prepare($sql);
$s->bindValue(':myname', $myname);
$s->bindValue(':myemail', $myemail);
$s->bindValue(':myrole', $myrole);
$s->bindValue(':myquestioncomment', $myquestioncomment);
$s->execute();
}
catch (PDOException $e)
{
$error = 'Error adding submitted registration: ' . $e->getMessage();
include '../includes/error.html.php';
exit();
}
require '../PHPMailer/PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP - requires a local mail server
//Faster and safer than using mail()
$mail->isSMTP();
$mail->Host = 'mail.$domain.tld';
$mail->Port = 465;
//Set this to true if SMTP host requires authentication to send email
$mail->SMTPAuth = true;
//Provide username and password
$mail->Username = "phpmailer@$domain.tld";
$mail->Password = "PASSWORD";
//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('phpmailer@$domain.tld', '[redacted]');
//Send the message to yourself, or whoever should receive contact for submissions
$mail->addAddress('$user@$domain.tld', '[redacted]');
//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
$mail->addReplyTo($myEmail, $myName);
$mail->Subject = 'AITH Contact Form';
//Keep it simple - don't use HTML
$mail->isHTML(true);
//Build a simple message body
$mail->Body = <<
Contact Email: $myemail
Whether the person is an athlete, volunteer or interested party: $myrole
Question or Comment: $myquestioncomment 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. echo "Mailer Error:" . $mail->ErrorInfo; } else { include 'success.html.php'; } //honey pot field $honeypot = $_POST['myname'>; //check if the honeypot field is filled out. If not, send a mail. if( !empty( $honeypot ) ){ return; } else{ include '../includes/error.html.php'; } } else { include 'contact.html.php'; } ?> contact.html.php
Whether the person is an athlete, volunteer or interested party: $myrole
Question or Comment: $myquestioncomment 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. echo "Mailer Error:" . $mail->ErrorInfo; } else { include 'success.html.php'; } //honey pot field $honeypot = $_POST['myname'>; //check if the honeypot field is filled out. If not, send a mail. if( !empty( $honeypot ) ){ return; } else{ include '../includes/error.html.php'; } } else { include 'contact.html.php'; } ?> contact.html.php
Name
Email
Question or Comment
You have registered as
Choose Your Role
Athlete
Volunteer
Interested Party
success.html.php
Thank you!
Our records show you submitted the following:
Name:
Email:
Question:
You have registered as:
Please sign in to leave a comment.
Comments
0 comments