I am using PHPMailer to send the email but I am getting an error.My domain is not SSL. If I am using smtp.gmail.com with my Gmail id then emails are going to inbox but when I am using my hosting details then I am getting an error
Warning: stream_socket_enable_crypto(): Peer certificate CN=`*.webhostbox.net' did not match expected CN=`mail.mydomain.com' in C:\xampp\htdocs\sendmail\mail\class.smtp.php on line 337
Mailer Error: SMTP connect() failed.
If I set $mail->SMTPSecure = 'tls';
to $mail->SMTPSecure = 'false'; then not getting an error but emails are going to spam.
Even I tried below code.
$mail->SMTPOptions = array (
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true));
Would you help me out in this?
Thank you
require 'mail/PHPMailerAutoload.php';
function sendMail($subject, $content, $email){
$phpMailerSubject = $subject;
$phpMailerText = $content;
$phpMailerTo = $email;
include 'mail/PHPMailerConfig.php';
}
PHPMailerConfig.php
<?php
//Create a new PHPMailer instance
$mail = new PHPMailer;
$mail->IsSMTP();
$mail->SMTPDebug = 0;
$mail->Debugoutput = 'html';
$mail->Host = 'mail.mydomain.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = "[email protected]";
$mail->Password = "Pass#@123";
$mail->setFrom('[email protected]', 'naren');
$mail->addReplyTo('[email protected]', 'naren');
$mail->addAddress($phpMailerTo, 'Customer');
$mail->Subject = $phpMailerSubject;
$mail->msgHTML($phpMailerText);
$mail->AltBody = ' ';
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) { echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "sucessfully";
}