World (N0C) + phpmailer + mailjet

Fredo

New Member
#1
Bonjour à tous,

j'ai besoin d'envoyer mes mails par mon smtp mailjet pour un projet et je deviens chèvre. Impossible d'envoyer le moindre mail.
J'ai bien installé phpmailer, mes clé api mailjet sont les bonnes et pourtant cela ne veut pas.
J'ai meme réalisé un simple fichier qui doit envoyer le mail, sans succès... J'ai toujours cette erreur :


2024-02-21 17:25:22 SERVER -> CLIENT:
SMTP Error: Could not connect to SMTP host.
Message could not be sent. Mailer Error: SMTP Error: Could not connect to SMTP host.

Vous n'auriez pas une idée ? Je suis perdu là...

Merci d'avance !

F.

#############################################
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);


//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;

//Load Composer's autoloader
require 'vendor/autoload.php';

//Create an instance; passing `true` enables exceptions
$mail = new PHPMailer(true);

try {
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'in-v3.mailjet.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = 'CLE1'; // Utiliser les clés API comme nom d'utilisateur
$mail->Password = 'CLE2'; // Utiliser les clés API comme mot de passe
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; //Enable implicit TLS encryption
$mail->Port = 587; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`

//Recipients
$mail->setFrom('[email protected]', 'fred');
$mail->addAddress('[email protected]', 'fred'); //Add a recipient




//Content
$mail->isHTML(true); //Set email format to HTML
$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';

$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}

?>
 
Haut