I know this question has been asked many times, but I don't find an answer to my problem.
I have the following code:
require 'vendor/autoload.php';
use PHPMailer\PHPMailer\PHPMailer;
$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'myEmailAddress@gmail.com';
$mail->Password = 'myPass';
$mail->Port = 587;
$mail->setFrom('myEmailAddress@gmail.com', 'Name Surname');
$mail->addAddress('myFriend@gmail.com', 'My Friend Mark');
$mail->Subject = 'Test';
$mail->isHTML(true);
$body = "<h1> TEST EMAIL </h1> <p> MY EMAIL IS AWESOME </p>";
$mail->Body = $body;
if($mail->send()){
echo "SENT!";
}else{
echo "Error ".$mail->ErrorInfo;
}
This works perfectly on my local server in Windows with XAMPP. When I try to run it on my OVH server I get
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Can someone help me?