IPB

Bienvenue invité ( Connexion | Inscription )

 
Reply to this topicStart new topic
> phpMailer : Could not instantiate mail function., Site migrer de Scalewqy vers Hostinger
Options
Eddoul
posté 2 Dec 2022, 18:19
Message #1


Macbidouilleur d'argent !
***

Groupe : Membres
Messages : 629
Inscrit : 21 Dec 2007
Membre no 103 074



Bonjour,

J'ai migré le site de notre asso de Scaleway vers Hostinger et plusieurs fonctionnalités ne marchent plus : envoi mails, génération PDF.
La version de php est 7.3, comme avant.

Pour l'envoi de mail, il y a un truc que je fais mail.
J'envoi des mails un par un (car en fonction de la personne, le texte peut varier).
Les 10 premiers passent bien, mais après j'ai cette erreur :
Code
Dans Envoyer_Le_Mail - Serveur : www.scf.asso.fr - Destinataire : '[email protected]'
Dans Envoyer_Le_Mail - Serveur : www.scf.asso.fr - Destinataire : '[email protected]'
Dans Envoyer_Le_Mail - Serveur : www.scf.asso.fr - Destinataire : '[email protected]'
Dans Envoyer_Le_Mail - Serveur : www.scf.asso.fr - Destinataire : '[email protected]'
Dans Envoyer_Le_Mail - Serveur : www.scf.asso.fr - Destinataire : '[email protected]'
Dans Envoyer_Le_Mail - Serveur : www.scf.asso.fr - Destinataire : '[email protected]'
Dans Envoyer_Le_Mail - Serveur : www.scf.asso.fr - Destinataire : '[email protected]'
Dans Envoyer_Le_Mail - Serveur : www.scf.asso.fr - Destinataire : '[email protected]'
Dans Envoyer_Le_Mail - Serveur : www.scf.asso.fr - Destinataire : '[email protected]'
Dans Envoyer_Le_Mail - Serveur : www.scf.asso.fr - Destinataire : '[email protected]' 2022-12-02 03:22:50 Could not instantiate mail function.

Pb d'envoi de mail


Expéditeur : [email protected]
Erreur : Could not instantiate mail function.
Sujet : SCF - Sortie club du 13/12/2022 à 07:00 à Hermance
Detinataire(s) : [email protected]
object(PHPMailer)#303 (75) { ["Version"]=> string(6) "5.2.15" ["Priority"]=> NULL ["CharSet"]=> string(5) "UTF-8" ["ContentType"]=> string(21) "multipart/alternative" ["Encoding"]=> string(4) "8bit" ["ErrorInfo"]=> string(36) "Could not instantiate mail function." ["From"]=> string(24) "[email protected]" ["FromName"]=> string(29) "Site du SCF - Eddy xxxx" ["Sender"]=> string(24) "[email protected]" ["ReturnPath"]=> string(0) "" ["Subject"]=> string(52) "SCF - Sortie club du 13/12/2022 à 07:00 à Hermance" ["Body"]=> string(4) "test" ["AltBody"]=> string(4) "test" ["Ical"]=> string(0) "" ["MIMEBody":protected]=> string(264) "This is a multi-part message in MIME format. --b1_29f12356a9b1da0828a57f7b5720efd4 Content-Type: text/plain; charset=us-ascii test --b1_29f12356a9b1da0828a57f7b5720efd4 Content-Type: text/html; charset=us-ascii test --b1_29f12356a9b1da0828a57f7b5720efd4-- " ["MIMEHeader":protected]=> string(401) "Date: Fri, 2 Dec 2022 03:22:50 +0000 From: Site du SCF - Eddy xxxx Reply-To: [email protected] Message-ID: <[email protected]> X-Mailer: PHPMailer 5.2.15 (https://github.com/PHPMailer/PHPMailer) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="b1_29f12356a9b1da0828a57f7b5720efd4" Content-Transfer-Encoding: 8bit " ["mailHeader":protected]=> string(112) "To: [email protected] Subject: =?UTF-8?Q?SCF_-_Sortie_club_du_13/12/2022_=C3=A0_07:00_=C3=A0_Hermance?= " ["WordWrap"]=> int(0) ["Mailer"]=> string(4) "mail" ["Sendmail"]=> string(18) "/usr/sbin/sendmail" ["UseSendmailOptions"]=> bool(true) ["PluginDir"]=> string(0) "" ["ConfirmReadingTo"]=> string(0) "" ["Hostname"]=> string(0) "" ["MessageID"]=> string(0) "" ["MessageDate"]=> string(30) "Fri, 2 Dec 2022 03:22:50 +0000" ["Host"]=> string(18) "smtp.hostinger.com" ["Port"]=> int(465) ["Helo"]=> string(0) "" ["SMTPSecure"]=> string(0) "" ["SMTPAutoTLS"]=> bool(true) ["SMTPAuth"]=> bool(true) ["SMTPOptions"]=> array(0) { } ["Username"]=> string(24) "[email protected]" ["Password"]=> string(15) "mot_passe@" ["AuthType"]=> string(0) "" ["Realm"]=> string(0) "" ["Workstation"]=> string(0) "" ["Timeout"]=> int(300) ["SMTPDebug"]=> int(2) ["Debugoutput"]=> string(4) "echo" ["SMTPKeepAlive"]=> bool(false) ["SingleTo"]=> bool(false) ["SingleToArray"]=> array(0) { } ["do_verp"]=> bool(false) ["AllowEmpty"]=> bool(false) ["LE"]=> string(1) " " ["DKIM_selector"]=> string(0) "" ["DKIM_identity"]=> string(0) "" ["DKIM_passphrase"]=> string(0) "" ["DKIM_domain"]=> string(0) "" ["DKIM_private"]=> string(0) "" ["action_function"]=> string(0) "" ["XMailer"]=> string(0) "" ["smtp":protected]=> NULL ["to":protected]=> array(1) { [0]=> array(2) { [0]=> string(25) "[email protected]" [1]=> string(0) "" } } ["cc":protected]=> array(0) { } ["bcc":protected]=> array(0) { } ["ReplyTo":protected]=> array(1) { ["[email protected]"]=> array(2) { [0]=> string(24) "[email protected]" [1]=> string(0) "" } } ["all_recipients":protected]=> array(1) { ["[email protected]"]=> bool(true) } ["RecipientsQueue":protected]=> array(0) { } ["ReplyToQueue":protected]=> array(0) { } ["attachment":protected]=> array(0) { } ["CustomHeader":protected]=> array(0) { } ["lastMessageID":protected]=> string(50) "<[email protected]>" ["message_type":protected]=> string(3) "alt" ["boundary":protected]=> array(3) { [1]=> string(35) "b1_29f12356a9b1da0828a57f7b5720efd4" [2]=> string(35) "b2_29f12356a9b1da0828a57f7b5720efd4" [3]=> string(35) "b3_29f12356a9b1da0828a57f7b5720efd4" } ["language":protected]=> array(19) { ["authenticate"]=> string(35) "SMTP Error: Could not authenticate." ["connect_host"]=> string(43) "SMTP Error: Could not connect to SMTP host." ["data_not_accepted"]=> string(30) "SMTP Error: data not accepted." ["empty_message"]=> string(18) "Message body empty" ["encoding"]=> string(18) "Unknown encoding: " ["execute"]=> string(19) "Could not execute: " ["file_access"]=> string(23) "Could not access file: " ["file_open"]=> string(33) "File Error: Could not open file: " ["from_failed"]=> string(35) "The following From address failed: " ["instantiate"]=> string(36) "Could not instantiate mail function." ["invalid_address"]=> string(17) "Invalid address: " ["mailer_not_supported"]=> string(25) " mailer is not supported." ["provide_address"]=> string(54) "You must provide at least one recipient email address." ["recipients_failed"]=> string(45) "SMTP Error: The following recipients failed: " ["signing"]=> string(15) "Signing Error: " ["smtp_connect_failed"]=> string(22) "SMTP connect() failed." ["smtp_error"]=> string(19) "SMTP server error: " ["variable_set"]=> string(30) "Cannot set or reset variable: " ["extension_missing"]=> string(19) "Extension missing: " } ["error_count":protected]=> int(1) ["sign_cert_file":protected]=> string(0) "" ["sign_key_file":protected]=> string(0) "" ["sign_extracerts_file":protected]=> string(0) "" ["sign_key_pass":protected]=> string(0) "" ["exceptions":protected]=> bool(false) ["uniqueid":protected]=> string(32) "29f12356a9b1da0828a57f7b5720efd4" }



Voici le code si ça peut aider :
CODE
function Envoyer_Le_Mail($lib_expediteur, $expediteur, $destinataire, $sujet, $corp_mail) {
// Report runtime errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);


// Report all errors
error_reporting(E_ALL);


// Same as error_reporting(E_ALL);
ini_set("error_reporting", E_ALL);

if ($expediteur == "") {
die("<br>fonctions_mail.Envoyer_Le_Mail($lib_expediteur, $expediteur, $destinataire, $sujet, $corp_mail)<br><h2 id='msgerreur'>L'expéditeur n'est pas renseigné</h2>");
}

if ($destinataire == "") {
die("<br>fonctions_mail.Envoyer_Le_Mail($lib_expediteur, $expediteur, $destinataire, $sujet, $corp_mail)<br><h2 id='msgerreur'>L'expéditeur n'est pas renseigné</h2>");
}

if ($expediteur == "") {
die("<br>fonctions_mail.Envoyer_Le_Mail($lib_expediteur, $expediteur, $destinataire, $sujet, $corp_mail)<br><h2 id='msgerreur'>L'expéditeur n'est pas renseigné</h2>");
}

if ($sujet == "") {
die("<br>fonctions_mail.Envoyer_Le_Mail($lib_expediteur, $expediteur, $destinataire, $sujet, $corp_mail)<br><h2 id='msgerreur'>L'expéditeur n'est pas renseigné</h2>");
}
if ($corp_mail == "") {
die("<br>fonctions_mail.Envoyer_Le_Mail($lib_expediteur, $expediteur, $destinataire, $sujet, $corp_mail)<br><h2 id='msgerreur'>L'expéditeur n'est pas renseigné</h2>");
}

$destinataire = '[email protected]';
$corp_mail = 'test';

if (file_exists('fonctions/fonctions_generales.php')) {
require_once 'fonctions/fonctions_generales.php';
}
else {
require_once '../../fonctions/fonctions_generales.php'; // cas où on est pas connecté, par ex : confirmation mail arrivé depuis lien du mail
}

// Si l'environnement n'est pas dans les variables SESSION, on le récupére dans la table paramétres
if (isset($_SESSION['Environnement'])) {
$Environnement = $_SESSION['Environnement'];
}
else {
$Environnement = Recup_Param('Environnement', '', '');
}

if (file_exists('classes/PHPMailer/PHPMailerAutoload.php')) {
require_once 'classes/PHPMailer/PHPMailerAutoload.php';
}
else {
require_once '../../classes/PHPMailer/PHPMailerAutoload.php'; // cas où on est pas connecté, par ex : confirmation mail arrivé depuis lien du mail
}

// Corp de notre email
if ($Environnement == "TEST") {
$sujet = "/!\/!\ ENV TEST /!\/!\ - " . $sujet;
$corp_mail = "<font color='red'>----- ENVIRONNEMENT DE TEST -----</font><br><br>$corp_mail";
}

try {
// Création d'un nouvel objet $mail
$mail = new PHPMailer();

/*
if (file_exists('classes/PHPMailer/language/phpmailer.lang-fr.php')) {
$mail->setLanguage('fr','classes/PHPMailer/language/phpmailer.lang-fr.php');
}
else {
$mail->setLanguage('fr','../../classes/PHPMailer/language/phpmailer.lang-fr.php');
}
*/

$mail->Host = 'smtp.hostinger.com';
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'mot_passe@';

$mail->SMTPDebug = true;
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->IsHTML(true);
$mail->CharSet = "UTF-8";

$mail->setFrom($expediteur, $lib_expediteur);
$mail->AddReplyTo($expediteur);

//$mail->addAddress($expediteur);//, $lib_expediteur);

$mail->Subject = $sujet;

$mail->MsgHTML($corp_mail);

$tab_dest = explode(",", $destinataire);
$Au_Moins_Un_DEstinataire = FALSE;
foreach ($tab_dest as $unDest) {
if ($unDest != '') {
$mail->addAddress($unDest);
$Au_Moins_Un_DEstinataire = TRUE;
}
}

// en local, on appele pas la fonction mail, par contre, on affiche le corps du mail
echo "<br>Dans Envoyer_Le_Mail - Serveur : " . $_SERVER['HTTP_HOST'] . " - Destinataire : '$destinataire' ";
if ($_SERVER['HTTP_HOST'] != "127.0.0.1" and $_SERVER['HTTP_HOST'] != "localhost:8888") {
if ($Au_Moins_Un_DEstinataire) {
if ( !$mail->Send() ) {
echo "<br><h2 id='msgerreur'>Pb d'envoi de mail</h2>";//var_dump($mail);
echo "<br>Expéditeur : $expediteur";
echo "<br>Erreur : " . $mail->ErrorInfo;
echo "<br><u>Sujet : </u> $sujet";
echo "<br><u>Detinataire(s) : </u> $destinataire<br>";
var_dump($mail);
die();
}
}
}
else {
Afficher_Mail($expediteur, $destinataire, $sujet, $corp_mail);
}

unset($mail);
}catch(phpmailerException $e) {
var_dump($mail);
die('<br><strong>Erreur : ' . $e->getMessage()) . "</strong></h4>";
}
}


Est-ce qu'il y a un pb dans le code ? Un mauvaise configuration sur le serveur ?
Bref, je nage complet pour ça.

Auriez-vous une idée ?

Merci pour votre aide.

Eddy


--------------------
Machines en ma possession :
- Imac 20", 4,3Ghz, HDD 250, 4Go RAM
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 utilisateur(s) sur ce sujet (1 invité(s) et 0 utilisateur(s) anonyme(s))
0 membre(s) :

 



Nous sommes le : 27th April 2024 - 00:22