Here is my code. I really need to know what is wrong with my code.I am getting this error:- "SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting"
<?php
require_once 'PHPMailer/class.phpmailer.php';
//sending mail for verification
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMTPAuth = true;
$mail->Port = 587;
$mail->Host = 'mail.mydomain.com';
$mail->Username = 'myusername'; // Enter your SMTP username
$mail->Password = "mypassword"; // SMTP password
$mail->From = "support@mydomain.com";
$mail->FromName = " Verification";
$mail->AddAddress("emailid@yahoo.com", "Name");
$mail->AddReplyTo("myemail@gmail.com", "Information");
$mail->IsHTML(true);
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body <b>in bold!</b>";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if($mail->Send()){
echo "Mail sent";
}else{
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
?>
My credentials are correct.I did follow the link in the error message and tried almost everything mentioned there but nothing seems to work for me. This is the shortest and trimmed version of my original code, the idea is to tell that even this is not working for me.