Contact Form not sending Email but success page appears


May 21, 2020
cPanel Access Level
Website Owner
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.


Contact Form [Moderator note: removed link]

* This example shows how to handle a simple contact form.

include '../includes/';

$msg = '';

//Don't run this unless we're handling a form submission
if (isset($_POST['myname']) AND empty($_POST['honeypot'])) {

$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);

catch (PDOException $e)
$error = 'Error adding submitted registration: ' . $e->getMessage();
include '../includes/error.html.php';

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->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 = "[email protected]$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('[email protected]$domain.tld', '[redacted]');
//Send the message to yourself, or whoever should receive contact for submissions
$mail->addAddress('[email protected]$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
//Build a simple message body
$mail->Body = <<<EOT
Contact Name: $myname<br>
Contact Email: $myemail<br>
Whether the person is an athlete, volunteer or interested party: $myrole<br>
Question or Comment: $myquestioncomment

//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 ) ){
include '../includes/error.html.php';


else {
include 'contact.html.php';


<form id="contactform" method="POST" action="success.html.php">

<div class="w3-section">
<label for="myname">Name</label>
<input class="w3-input w3-border" type="text" name="myname" id="myname" required>
<div class="w3-section">
<label for="myemail">Email</label>
<input class="w3-input w3-border" type="text" name="myemail" id="myemail" required>
<div class="w3-section">
<label for="myquestioncomment">Question or Comment</label>
<input class="w3-input w3-border" type="text" name="myquestioncomment" id="myquestioncomment" required>
<div class="w3-section">
<label for="myrole">You have registered as</label>
<select class="w3-input w3-border" size="1" name="myrole" id="myrole" required>
<option value="">Choose Your Role</option>
<option value="Athlete">Athlete</option>
<option value="Volunteer">Volunteer</option>
<option value="Interested">Interested Party</option>

<input id="mysubmit" type="submit" class="w3-button w3-block w3-padding-large w3-red w3-margin-bottom" value="Submit">




<?php include '../includes/'; ?>

<h1>Thank you!</h1>
<p>Our records show you submitted the following:<br>
Name: <?php echo htmlspecialchars($myname, ENT_QUOTES); ?> <br>
Email: <?php echo htmlspecialchars($myemail, ENT_QUOTES); ?> <br>
Question: <?php echo htmlspecialchars($myquestioncomment, ENT_QUOTES); ?><br>
You have registered as: <?php echo htmlspecialchars($myrole, ENT_QUOTES); ?><br>

[Moderator note: removed personal identifying information]
Last edited by a moderator:


Well-Known Member
Staff member
Nov 20, 2019
cPanel Access Level
Root Administrator
Hello @missteelee

I reviewed the PHPMailer authentication settings you put in your script and confirmed the mail host is connectable on the specified port. As long as the username and password are also correct, PHPMailer should be able to send the message.

Did you review the Dovecot authentication log /var/log/maillog and the Exim log /var/log/exim_mainlog for any error messages? Any errors that might have been recorded in these logs would help to identify any potential configuration issues in your PHP scripts.

Please let us know if you have any questions.