I am having a form on my HTML website and sending contact form emails via PHP functions.
Below is the code I have in php email sending file...
if( file_exists($php_email_form = '../assets/vendor/php-email-form/php-email-form.php' )) {
include( $php_email_form );
} else {
die( 'Unable to load the "PHP Email Form" Library!');
}
$mail = new PHPMailer(true);
$mail->isSMTP();// Set mailer to use SMTP
$mail->CharSet = "utf-8";// set charset to utf8
$mail->SMTPAuth = true;// Enable SMTP authentication
$mail->SMTPSecure = false;// Enable TLS encryption, `ssl` also accepted
$mail->Host = 'mail.example.com';// Specify main and backup SMTP servers
$mail->Port = 587;// TCP port to connect to
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->isHTML(true);// Set email format to HTML
$mail->Username = 'webmail@example.com';// SMTP username
$mail->Password = 'Password';// SMTP password
$mail->setFrom('webmail@example.com', 'WebForm Submission');//Your application NAME and EMAIL
$mail->Subject = 'Test';//Message subject
$mail->MsgHTML('HTML code');// Message body
$mail->addAddress('webmail@example.com', 'User Name');// Target email
// $mail->send();
if(!$mail->Send()) {
echo "<p class='error'>Problem in Sending Mail.</p>";
echo $mail->ErrorInfo;
} else {
echo "<p class='success'>Contact Mail Sent. for sure</p>";
}
After submission, I am getting messages as
Error:
Contact Mail Sent...
can anybody help me, with why there is a success message along with the error