I am using PHPMailer to send mails from website to a specific address
Here is my configuration :
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8'; // Format d'encodage à utiliser pour les caractères
$mail->SMTPDebug = 4; // Valeur entre 0 (normal) et 4 (full debug). Attention : mettre cette valeur > 0 dévoule certains paramètres confidentiels !
$mail->isSMTP();
$mail->Host = 'smtp.office365.com'; // Adresse IP ou DNS du serveur SMTP
$mail->Port = 587; // Port TCP du serveur SMTP (port SMTP chez OVH : 465=avec_SSL et 587=sans_SSL/avec_tls)
$mail->SMTPAuth = TRUE; // Utiliser l'authentification
$mail->SMTPSecure = 'TLS';
$mail->Username = 'email@xyz.x';
$mail->Password = 'PWD';
I enabled and enforced the multifactor authentication and created an app password that i put in $mail->Password.
I still get the same erreur :
2023-01-09 14:32:53 Connection: opening to smtp.office365.com:587, timeout=300, options=array()
2023-01-09 14:32:53 Connection failed. Error #2: stream_socket_client(): Unable to connect to smtp.office365.com:587 (Connection refused) [/home/vendor/phpmailer/phpmailer/src/SMTP.php line 388]
2023-01-09 14:32:53 SMTP ERROR: Failed to connect to server: Connection refused (111)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
I tried every solution i found on google but nothing seems to work.. the website host is ** OVH **.
I tried with and without the MFA but i get the same results.. if anyone was facing the same problem and found a working solution i'd be so grateful !
Thanks in advance