Page blanche Phpmailer
Résolu
djstoun
Messages postés
290
Date d'inscription
Statut
Membre
Dernière intervention
-
djstoun Messages postés 290 Date d'inscription Statut Membre Dernière intervention -
djstoun Messages postés 290 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
J'ai testé Phpmailer car mon hébergeur a bloqué temporairement la fonction mail(). J'ai essayé de voir sur des forums et les tutos mais je n'y arrive pas. J'ai essayé de faire une page test de mon site mais à chaque fois, j'ai une page blanche. Pouvez-vous m'aider ? J'ai mis un des codes php que j'ai utilisé en bas de ce message.
Merci d'avance,
J'ai testé Phpmailer car mon hébergeur a bloqué temporairement la fonction mail(). J'ai essayé de voir sur des forums et les tutos mais je n'y arrive pas. J'ai essayé de faire une page test de mon site mais à chaque fois, j'ai une page blanche. Pouvez-vous m'aider ? J'ai mis un des codes php que j'ai utilisé en bas de ce message.
Merci d'avance,
<?php require_once('/phpmailer/class.phpmailer.php'); $mail = new PHPMailer(); $mail->IsHTML(true); $mail->CharSet = "utf-8"; $mail->SetFrom('adresse-mail@gmail.com', 'Expéditeur'); $mail->Subject = 'Signalement erreur PHP'; $mail->Body = '<p><b>E-Mail</b> au format <i>HTML</i>.</p>'; $mail->AddAddress('adresse-mail@gmail.com'); $mail->Send(); ?>
A voir également:
- Comme ca fonction phpmailer
- Fonction si et - Guide
- Fonction miroir - Guide
- Fonction moyenne excel - Guide
- Fonction remplacer sur word - Guide
- Fonction somme excel - Guide
8 réponses
Bonjour
tu as essayé de faire :
tu as essayé de faire :
if($mail->Send()){ echo "<br>Mail envoyé avec succès !"; }else{ echo "<br>ERREUR !"; }
Testes ça :
EDIT : Penses à mettre à jour les données qui se trouvent dans :
"AUTHENTIFICATION AU SMTP"
<?php ini_set('display_errors', '1'); error_reporting(E_ALL); echo "<pre>DEBUT DU SCRIPT<br>"; require_once('/phpmailer/class.phpmailer.php'); include("/phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $body = "Hello, \n Ceci est un test !!!"; $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "mail.yourdomain.com"; // SMTP server $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only //*************** AUTHENTIFICATION AU SMTP *****************************// $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "mail.yourdomain.com"; // sets the SMTP server $mail->Port = 26; // set the SMTP port for the MAIL server $mail->Username = "yourname@yourdomain"; // SMTP account username $mail->Password = "yourpassword"; // SMTP account password //***********************************************************************// $mail->SetFrom('pourquivoter@yahoo.fr', 'Expéditeur'); $mail->AddReplyTo("pourquivoter@yahoo.fr","First Last"); $mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $address = "pourquivoter@yahoo.fr"; $mail->AddAddress($address, "pourquivoter"); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?>
EDIT : Penses à mettre à jour les données qui se trouvent dans :
"AUTHENTIFICATION AU SMTP"
Cela me fait une page blanche où il est simplement écrit "DEBUT DU SCRIPT".
Voici mon code :
Voici mon code :
<?php ini_set('display_errors', '1'); error_reporting(E_ALL); echo "<pre>DEBUT DU SCRIPT<br>"; require_once('/phpmailer/class.phpmailer.php'); include("/phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $body = "Hello, \n Ceci est un test !!!"; $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.mail.yahoo.com"; // SMTP server $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only //*************** AUTHENTIFICATION AU SMTP *****************************// $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "smtp.mail.yahoo.com"; // sets the SMTP server $mail->Port = 587; // set the SMTP port for the MAIL server $mail->Username = "pourquivoter@yahoo.fr"; // SMTP account username $mail->Password = "******"; // SMTP account password //***********************************************************************// $mail->SetFrom('pourquivoter@yahoo.fr', 'Expéditeur'); $mail->AddReplyTo("pourquivoter@yahoo.fr","First Last"); $mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $address = "pourquivoter@yahoo.fr"; $mail->AddAddress($address, "pourquivoter"); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } ?>
C'est vraiment étrange ton truc.....
On va ajouter un peu de debug ....
On va ajouter un peu de debug ....
<?php ini_set('display_errors', '1'); error_reporting(E_ALL); $debug=0; echo "<pre>DEBUT DU SCRIPT</pre>"; $debug++; echo "<br> DEBUG :".$debug; require_once('/phpmailer/class.phpmailer.php'); include("/phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $debug++; echo "<br> DEBUG :".$debug; $body = "Hello, \n Ceci est un test !!!"; $mail = new PHPMailer(); $debug++; echo "<br> DEBUG :".$debug; $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.mail.yahoo.com"; // SMTP server $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $debug++; echo "<br> DEBUG :".$debug; //*************** AUTHENTIFICATION AU SMTP *****************************// $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "smtp.mail.yahoo.com"; // sets the SMTP server $mail->Port = 587; // set the SMTP port for the MAIL server $mail->Username = "pourquivoter@yahoo.fr"; // SMTP account username $mail->Password = "******"; // SMTP account password //***********************************************************************// $debug++; echo "<br> DEBUG :".$debug; $mail->SetFrom('pourquivoter@yahoo.fr', 'Expéditeur'); $mail->AddReplyTo("pourquivoter@yahoo.fr","First Last"); $mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $address = "pourquivoter@yahoo.fr"; $mail->AddAddress($address, "pourquivoter"); $debug++; echo "<br> DEBUG :".$debug; if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } $debug++; echo "<br> DEBUG :".$debug; echo "<pre>FIN DU SCRIPT</pre>"; ?>
Donc il ne dépasse pas l'import des fichiers phpmailer...
tu es sûr du chemin ??
Testes ceci :
tu es sûr du chemin ??
Testes ceci :
<?php ini_set('display_errors', '1'); error_reporting(E_ALL); $debug=0; echo "<pre>DEBUT DU SCRIPT</pre>"; $debug++; echo "<br> DEBUG :".$debug; $phpmailerClass = "/phpmailer/class.phpmailer.php"; if(file_exists($phpmailerClass)){ echo "<br>ok : Fichier $phpmailerClass trouvé ! "; require_once($phpmailerClass); include("/phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded }else{ echo "<br>Error : Fichier $phpmailerClass non trouvé ! "; } $debug++; echo "<br> DEBUG :".$debug; $body = "Hello, \n Ceci est un test !!!"; $mail = new PHPMailer(); $debug++; echo "<br> DEBUG :".$debug; $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.mail.yahoo.com"; // SMTP server $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $debug++; echo "<br> DEBUG :".$debug; //*************** AUTHENTIFICATION AU SMTP *****************************// $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "smtp.mail.yahoo.com"; // sets the SMTP server $mail->Port = 587; // set the SMTP port for the MAIL server $mail->Username = "pourquivoter@yahoo.fr"; // SMTP account username $mail->Password = "******"; // SMTP account password //***********************************************************************// $debug++; echo "<br> DEBUG :".$debug; $mail->SetFrom('pourquivoter@yahoo.fr', 'Expéditeur'); $mail->AddReplyTo("pourquivoter@yahoo.fr","First Last"); $mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication"; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $address = "pourquivoter@yahoo.fr"; $mail->AddAddress($address, "pourquivoter"); $debug++; echo "<br> DEBUG :".$debug; if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } $debug++; echo "<br> DEBUG :".$debug; echo "<pre>FIN DU SCRIPT</pre>"; ?>
En revanche si je fais le code tout simple :
Cela me marque bien "ok : Fichier phpmailer/class.phpmailer.php trouvé !"
<?php ini_set('display_errors', '1'); error_reporting(E_ALL); $phpmailerClass = "phpmailer/class.phpmailer.php"; if(file_exists($phpmailerClass)){ echo "<br>ok : Fichier $phpmailerClass trouvé ! "; require_once($phpmailerClass); include("phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded }else{ echo "<br>Error : Fichier $phpmailerClass non trouvé ! "; } ?>
Cela me marque bien "ok : Fichier phpmailer/class.phpmailer.php trouvé !"
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Vides bien ton cache et teste ce code :
<?php // AFFICHAGE DES ERREURS: ini_set('display_errors', '1'); error_reporting(E_ALL); /** * Fonction d'envoi de mails */ function SendMail($to,$sujet,$body){ //Include des class : $phpmailerClass = "/phpmailer/class.phpmailer.php"; if(file_exists($phpmailerClass)){ echo "<br>ok : Fichier $phpmailerClass trouvé ! "; require_once($phpmailerClass); include("/phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded }else{ echo "<br>Error : Fichier $phpmailerClass non trouvé ! "; } //-------------------------------------------------------------------------------// try{ //Objet Mail $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.mail.yahoo.com"; // SMTP server $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only //*************** AUTHENTIFICATION AU SMTP *****************************// $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "smtp.mail.yahoo.com"; // sets the SMTP server $mail->Port = 587; // set the SMTP port for the MAIL server $mail->Username = "pourquivoter@yahoo.fr"; // SMTP account username $mail->Password = "******"; // SMTP account password //***********************************************************************// $mail->SetFrom('pourquivoter@yahoo.fr', 'Expéditeur'); $mail->AddReplyTo("pourquivoter@yahoo.fr","First Last"); $mail->Subject = $sujet; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $mail->AddAddress($to, "pourquivoter"); if(!$mail->Send()){ $result = "Mailer Error: " . $mail->ErrorInfo; }else{ $result=false; } } catch (Exception $e) { $result = '<br>Exception reçue : ' . $e->getMessage(). "\n"; } return $result; } //---------------------------------------------------------------------------------------------// echo "<pre>DEBUT DU SCRIPT</pre>"; $address = "pourquivoter@yahoo.fr"; $message = " <pre> Ceci est un message Test. </pre>"; $sujet = "Mail de Test"; // envoie du mail echo "<pre>Envoi du mail :"; $sendMail = SendMail($address,$sujet,$message); if(!$sendMail) { echo "<br> Message envoyé!"; }else{ echo "<br>".$sendMail; } echo "</pre>"; echo "<pre>FIN DU SCRIPT</pre>"; //---------------------------------------------------------------------------------------------// ?>
Je te mets mon code : (mais on est d'accord il faut bien mettre le smtp de yahoo, c'est à dire celui de mon adresse mail ?)
<?php // AFFICHAGE DES ERREURS: ini_set('display_errors', '1'); error_reporting(E_ALL); /** * Fonction d'envoi de mails */ function SendMail($to,$sujet,$body){ //Include des class : $phpmailerClass = "phpmailer/class.phpmailer.php"; if(file_exists($phpmailerClass)){ echo "<br>ok : Fichier $phpmailerClass trouvé ! "; require_once($phpmailerClass); include("phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded }else{ echo "<br>Error : Fichier $phpmailerClass non trouvé ! "; } //-------------------------------------------------------------------------------// try{ //Objet Mail $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.mail.yahoo.com"; // SMTP server $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only //*************** AUTHENTIFICATION AU SMTP *****************************// $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "smtp.mail.yahoo.com"; // sets the SMTP server $mail->Port = 587; // set the SMTP port for the MAIL server $mail->Username = "pourquivoter@yahoo.fr"; // SMTP account username $mail->Password = "****"; // SMTP account password //***********************************************************************// $mail->SetFrom('pourquivoter@yahoo.fr', 'Expéditeur'); $mail->AddReplyTo("pourquivoter@yahoo.fr","First Last"); $mail->Subject = $sujet; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $mail->AddAddress($to, "pourquivoter"); if(!$mail->Send()){ $result = "Mailer Error: " . $mail->ErrorInfo; }else{ $result=false; } } catch (Exception $e) { $result = '<br>Exception reçue : ' . $e->getMessage(). "\n"; } return $result; } //---------------------------------------------------------------------------------------------// echo "<pre>DEBUT DU SCRIPT</pre>"; $address = "pourquivoter@yahoo.fr"; $message = " <pre> Ceci est un message Test. </pre>"; $sujet = "Mail de Test"; // envoie du mail echo "<pre>Envoi du mail :"; $sendMail = SendMail($address,$sujet,$message); if(!$sendMail) { echo "<br> Message envoyé!"; }else{ echo "<br>".$sendMail; } echo "</pre>"; echo "<pre>FIN DU SCRIPT</pre>"; //---------------------------------------------------------------------------------------------// ?>
Bonsoir
Juste une petite remarque :
Dans ton script simple, tu écris "phpmailer/class.phpmailer.php" (pas de / au début
Dans ceux qui ne marchent pas, tu écris "/phpmailer/class.phpmailer.php"
Si c'est ça la raison, bizarre qu'il n'y ait pas de message d'erreur quand même
Juste une petite remarque :
Dans ton script simple, tu écris "phpmailer/class.phpmailer.php" (pas de / au début
Dans ceux qui ne marchent pas, tu écris "/phpmailer/class.phpmailer.php"
Si c'est ça la raison, bizarre qu'il n'y ait pas de message d'erreur quand même
Je viens de fouiller un peu sur le net ... et visiblement.... avec Yahoo ... seuls les comptes "pro" peuvent envoyer des mails depuis des scripts PHP.....
A mon avis, tu ferais mieux de passer par Gmail.
A mon avis, tu ferais mieux de passer par Gmail.
<?php // AFFICHAGE DES ERREURS: ini_set('display_errors', '1'); error_reporting(E_ALL); function sendMail($to,$sujet,$body,$pj=NULL){ //***** VARIABLES *****// $user = "tonadresseMail"; $password ="tonPassword"; $fromMail = "tonadresseMail"; $fromName = "Moi"; $replytoMail = "tonadresseMail"; $replytoName = "Moi"; // Parametres SMTP $host = 'smtp.gmail.com'; $port = 587; //---------------------// $result=array(); //Include des class : $phpmailerClass = "phpmailer/class.phpmailer.php"; if(file_exists($phpmailerClass)){ require_once($phpmailerClass); include("phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded }else{ $result['error'] = "<br>Error : Fichier $phpmailerClass non trouvé ! "; return $result; } //-------------------------------------------------------------------------------// try{ //Objet Mail $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only //Ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //*************** AUTHENTIFICATION AU SMTP *****************************// //Set the encryption system to use - ssl (deprecated) or tls $mail->SMTPSecure = 'tls'; $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = $host; // sets the SMTP server $mail->Port = $port; // set the SMTP port for the MAIL server $mail->Username = $user; // SMTP account username $mail->Password = $password; // SMTP account password //***********************************************************************// $mail->SetFrom($fromMail, $fromName); $mail->AddReplyTo($replytoMail,$replytoName); $mail->Subject = $sujet; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $mail->AddAddress($to); if(!$mail->Send()){ $result['error'] = "Mailer Error: " . $mail->ErrorInfo; $result['status'] = false; }else{ $result['error'] = false; $result['status'] = true; } } catch (Exception $e) { $result['error'] = '<br>Exception reçue : ' . $e->getMessage(). "\n"; $result['status'] = false; } return $result; } //-------- debut du script -------------------// echo "<br>" . date('Y-m-d H:i:s') . " Debut du script "; $destinataire = "uneadresse@toto.com"; $sujet = "ceci est un mail test"; $message = " Youpii.. ça marche ..."; print_r( sendMail($destinataire,$sujet,$message)); echo "<br>" . date('Y-m-d H:i:s') . " Fin du script "; ?>
Sur la page cela m'affiche : 2015-03-16 22:24:09 Debut du script
Et toujours pas de mail reçu sur la nouvelle boite mail. J'ai essayé en changeant le port à 25 et 465.
Et toujours pas de mail reçu sur la nouvelle boite mail. J'ai essayé en changeant le port à 25 et 465.
<?php // AFFICHAGE DES ERREURS: ini_set('display_errors', '1'); error_reporting(E_ALL); function sendMail($to,$sujet,$body,$pj=NULL){ //***** VARIABLES *****// $user = "pourquivoter@gmail.com"; $password ="*****"; $fromMail = "pourquivoter@gmail.com"; $fromName = "Moi"; $replytoMail = "pourquivoter@gmail.com"; $replytoName = "Moi"; // Parametres SMTP $host = 'smtp.gmail.com'; $port = 587; //---------------------// $result=array(); //Include des class : $phpmailerClass = "phpmailer/class.phpmailer.php"; if(file_exists($phpmailerClass)){ require_once($phpmailerClass); include("phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded }else{ $result['error'] = "<br>Error : Fichier $phpmailerClass non trouvé ! "; return $result; } //-------------------------------------------------------------------------------// try{ //Objet Mail $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only //Ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //*************** AUTHENTIFICATION AU SMTP *****************************// //Set the encryption system to use - ssl (deprecated) or tls $mail->SMTPSecure = 'tls'; $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = $host; // sets the SMTP server $mail->Port = $port; // set the SMTP port for the MAIL server $mail->Username = $user; // SMTP account username $mail->Password = $password; // SMTP account password //***********************************************************************// $mail->SetFrom($fromMail, $fromName); $mail->AddReplyTo($replytoMail,$replytoName); $mail->Subject = $sujet; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $mail->AddAddress($to); if(!$mail->Send()){ $result['error'] = "Mailer Error: " . $mail->ErrorInfo; $result['status'] = false; }else{ $result['error'] = false; $result['status'] = true; } } catch (Exception $e) { $result['error'] = '<br>Exception reçue : ' . $e->getMessage(). "\n"; $result['status'] = false; } return $result; } //-------- debut du script -------------------// echo "<br>" . date('Y-m-d H:i:s') . " Debut du script "; $destinataire = "pourquivoter@gmail.com"; $sujet = "ceci est un mail test"; $message = " Youpii.. ça marche ..."; print_r( sendMail($destinataire,$sujet,$message)); echo "<br>" . date('Y-m-d H:i:s') . " Fin du script "; ?>
Il semble qu'il y ai un souci de connexion au SMTP de google....
bizarre....
TU peux tester ça :
bizarre....
TU peux tester ça :
<?php // AFFICHAGE DES ERREURS: ini_set('display_errors', '1'); error_reporting(E_ALL); function testCnx($host,$port){ try{ $checkconn = fsockopen($host, $port, $errno, $errstr, 10); if(!$checkconn){ echo "<br>($errno) $errstr"; $result=false; } else { echo 'ok'; $result=true; } } catch (Exception $e) { echo $e->getMessage(); echo "<br>($errno) $errstr"; $result=false; } return $result; } function sendMail($to,$sujet,$body,$pj=NULL){ //***** VARIABLES *****// //Include des class : $phpmailerClass = "phpmailer/class.phpmailer.php"; require_once($phpmailerClass); include("phpmailer/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded $user = "monemail@gmail.com"; $password ="*****"; $fromMail = "monemail@gmail.com"; $fromName = "Moi"; $replytoMail = "monemail@gmail.com"; $replytoName = "Moi"; // Parametres SMTP $host = 'smtp.gmail.com'; $port = 587; //---------------------// $result=array(); if(!testCnx($host,$port)){ exit(); } //-------------------------------------------------------------------------------// try{ //Objet Mail $mail = new PHPMailer(true); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only //Ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //*************** AUTHENTIFICATION AU SMTP *****************************// //Set the encryption system to use - ssl (deprecated) or tls $mail->SMTPSecure = 'tls'; $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = $host; // sets the SMTP server $mail->Port = $port; // set the SMTP port for the MAIL server $mail->Username = $user; // SMTP account username $mail->Password = $password; // SMTP account password //***********************************************************************// $mail->WordWrap = 900; $mail->ContentType = 'text/html; charset=utf-8\r\n'; $mail->CharSet = 'UTF-8'; $mail->Encoding = '8bit'; $mail->SetFrom($fromMail, $fromName); $mail->AddReplyTo($replytoMail,$replytoName); $mail->Subject = $sujet; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test $mail->MsgHTML($body); $mail->AddAddress($to); if(!$mail->Send()) { $result[] = 'Mail error: '.$mail->ErrorInfo; } else { echo "<br>".date('Y-m-d'). " Mail envoyé OK"; $result[] = true; } } catch (phpmailerException $e) { echo $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! } $mail->SmtpClose(); return $result; } //-------- debut du script -------------------// echo "<br>" . date('Y-m-d H:i:s') . " Debut du script "; $destinataire = "jordane.reynet@atos.net"; $sujet = "ceci est un mail test"; $message = " Youpii.. ça marche ..."; print_r(sendMail($destinataire,$sujet,$message)); echo "<br>" . date('Y-m-d H:i:s') . " Fin du script "; ?>
j'ai retesté le script ...
Il fonctionne très bien (en local chez moi) .. mais ne passe pas lorsque je suis au travail car le port est bloqué !
Si ça se trouve... ton problème ...c'est juste une question de port bloqué..... (par le FireWall ou le routeur ou le proxy par exemple). Mais dans ce cas... je n'ai aucune solution pour contourner le problème.
Il fonctionne très bien (en local chez moi) .. mais ne passe pas lorsque je suis au travail car le port est bloqué !
Si ça se trouve... ton problème ...c'est juste une question de port bloqué..... (par le FireWall ou le routeur ou le proxy par exemple). Mais dans ce cas... je n'ai aucune solution pour contourner le problème.
Alors j'ai pu enfin retransférer la page sur mon FTP. J'ai eu ce message, à toi de me dire, si y a moyen de résoudre ou pas :
"
2015-03-23 13:55:29 Debut du script okSMTP -> ERROR: EHLO not accepted from server:
SMTP -> ERROR: HELO not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedLanguage string failed to load: tls
Array ( )
2015-03-23 13:55:55 Fin du script"
"
2015-03-23 13:55:29 Debut du script okSMTP -> ERROR: EHLO not accepted from server:
SMTP -> ERROR: HELO not accepted from server:
SMTP -> NOTICE: EOF caught while checking if connectedLanguage string failed to load: tls
Array ( )
2015-03-23 13:55:55 Fin du script"
Youpi !
J'ai en fait cette fois-ci paramétrer sur une adresse hotmail et cela fonctionne ! Merci à toi Jordane45. Maintenant, je vais essayer d'arriver à mes fins avec cette utilisation de Phpmailer. (peut-être que j'aurais de nouveau besoin de tes conseils du coup.)^^
Voici le code hotmail qui fonctionne, pour ceux qui s'arrachent les cheveux.
J'ai en fait cette fois-ci paramétrer sur une adresse hotmail et cela fonctionne ! Merci à toi Jordane45. Maintenant, je vais essayer d'arriver à mes fins avec cette utilisation de Phpmailer. (peut-être que j'aurais de nouveau besoin de tes conseils du coup.)^^
Voici le code hotmail qui fonctionne, pour ceux qui s'arrachent les cheveux.
require "phpmailer/class.phpmailer.php"; $mail = new PHPmailer(); $mail->IsSMTP(); $mail->IsHTML(true); $mail->Host='smtp.live.com'; //aussi essayé smtp.mondomaine.com $mail->Port=587; $mail->Username = 'yourmail@hotmail.com'; // SMTP login $mail->Password = '*******'; // SMTP password $mail->SMTPAuth = true; // Active l'uthentification par smtp $mail->SMTPSecure = 'tls'; $mail->From='yourmail@hotmail.com'; $mail->AddAddress('yourmail@hotmail.com'); $mail->AddReplyTo('yourmail@hotmail.com'); $mail->Subject='Exemple trouvé sur DVP'; $mail->Body='<html><body><head><style>.entete{background-color:#0000FF;color:#FFFFFF;border:solid 3px;font-size:25px}'; $mail->Body.='.ligne{color:#0000FF;border:solid 1px;text-align:center;font-size:23px}</style></head>'; $mail->Body.='<center><table><tr><td class="entete">Voici un exemple d\'e-mail au format HTML</td></tr>'; $mail->Body.='<tr><td class="ligne">Ceci est un tableau HTML</td></tr></table></center></body></html>'; if(!$mail->Send()){ //Teste si le return code est ok. echo $mail->ErrorInfo; //Affiche le message d'erreur } else{ echo 'Mail envoyé avec succès'; } $mail->SmtpClose(); unset($mail);
et dis nous si ça t'affiche quelque chose.
Et tu l'appelles comment cette page ?
Via un formulaire HTML ?
Tu nous montres son code ?
Cette page je l'ai créée pour essayer si Phpmailer fonctionnait. En effet, je compte l'utiliser ensuite pour m'envoyer les résultats d'un questionnaire test.
Voici le code complet de cette simple page test :