Hello Zoho team,
I am trying to configure email on my website but getting the following error:
2018-10-21 05:35:39 Connection: opening to smtp.zoho.com:587, timeout=300, options=array()
2018-10-21 05:35:40 SMTP ERROR: Failed to connect to server: Connection refused (111)
I have used the following code.. please suggest me a solution for the same
<?php
use PHPMailer\PHPMailer\PHPMailer;
require 'vendor/autoload.php';
$txt = "<html>
<head>
<title>M/s VIKASH TECH</title>
</head>
<body>
Name - ".$_POST['name']."<br/>
Email - ".$_POST['email']."<br/>
Number - ".$_POST['number']."<br/>
Message - ".$_POST['message']."<br/>
</body>
</html>
";
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 4;
$mail->Host = 'smtp.zoho.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Password = '---mypassword---';
$mail->addAddress($_POST['email']);
$mail->Subject = "Contact Request";
//$mail->Body = $_SESSION['msg'].$_SESSION['otp'].$_SESSION['note'];
$mail->msgHTML($txt, __DIR__);
if (!$mail->send()) {
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'OK';
}
?>