Bonjour, j'ai un souci avec mon hebergement mutualié en fait la fonction mail() est apparement bloquée ( ne fonctionne pas) on m'a conseiller PHPMailler mais je n'y arrive pas
J'ai un email professionnel sur Office 365 et suis hebergé chez Goddady serveur windows PLESK
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//Load composer's autoloader
require 'vendor/autoload.php';
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.office365.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'Mon email'; // SMTP username
$mail->Password = '*******!'; // SMTP password
//$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
//$mail->SMTPSecure = 'ssl';
$mail->SMTPSecure = 'starttls';
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('info@moi.com', 'Moi');
$mail->addAddress('contact@gmail.com', 'Lui'); // Add a recipient
$mail->addAddress('info@domaine.com'); // Name is optional
//$mail->addReplyTo('info@example.com', 'Information');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
//Attachments
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Pour tester mes messages';
$mail->Body = 'Mon petit sa vas?? <br> Suis à la ligne <b>Cool<b>';
//$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo 'Erreur.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
J'ai cette erreur :
2019-05-28 04:49:11 SMTP ERROR: Failed to connect to server: An attempt was made to access a socket in a way forbidden by its access permissions. (10013)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Erreur.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Merci de m'aider