Fonction php mail chez ovh

Bonjour à tous,
J'ai un problème avec la fonction mail() en php sur mon site chez OVH.
En local ça marche parfaitement avec WAMP.
Sur mon vrai site chez ovh ça ne marche pas je ne comprends pas.
j'ai l'offre mutualisé freedom perso avec 500mails/j.

 // Envoi d'email
            $mail_To = monmail@laposte.net;
            $mail_Subject = "test mail";
			

			
            $headers  = "From: monsite.com\n"; 
            $headers .= "Reply-To: postmaster@monsite.com\n";
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Transfer-Encoding: 8bit\n";
            $headers .= "Content-type: text/html; charset=utf-8\n";
                      
            $mail_Body = 'Bonjour ';

            if(mail($mail_To, $mail_Subject, $mail_Body, $headers)) 
               { 
                   $_SESSION['message'] ='ok good';
                   unset($_POST);
               } 
               else 
               { 
                    $_SESSION['erreur'] ="bug complet";
               } 
			   */



avez vous une solution ou des conseils?
Merci d'avance =)

10 réponses

  1. Bonjour,

    Avez-vous accès aux réglages du php.ini sur votre serveur ?

    Cordialement
    0
    1. salut essayes en mettant:

       $headers  = "From: monsite.com"."\n";

      au lieu de $headers = "From: monsite.com\n";
      idem pour chaque ligne de headers
      0
      1. thorak 83 je ne sais pas. peut être peut être pas je vais voir

        je test alain42
        0
        1. Non sur un mutualisé il n'y a pas d'accès au php.ini

          alain ça ne marche pas deg :(

          mais ça doit venir de leur serveur car j'ai testé des codes différents certifié marcher par d'autres membres ovh et sur mon site ça ne marche pas
          0
          1. Quelle erreur affiche le script ?
            0
            1. sur mon code rien j'ai juste $_SESSION['erreur'] ="bug complet";

              sur le code que j'ai trouvé sur le net j'ai un CR_MAIL=== False

              // Test fonction mail();
              
                 // *** A configurer
              
                 $to    = "monmail@laposte.net";  
                 $from  = "postmaster@monsite.com";     // adresse MAIL OVH liée à ton hébergement.
              
                 // *** Laisser tel quel
              
                 $JOUR  = date("Y-m-d");
                 $HEURE = date("H:i");
              
                 $Subject = "Test Mail - $JOUR $HEURE";
              
                 $mail_Data = "";
                 $mail_Data .= "<html> \n";
                 $mail_Data .= "<head> \n";
                 $mail_Data .= "<title> Subject </title> \n";
                 $mail_Data .= "</head> \n";
                 $mail_Data .= "<body> \n";
              
                 $mail_Data .= "Mail HTML simple  : <font color=red> <b>$Subject </b> </font>  <br> \n";
                 $mail_Data .= "<br> \n";
                 $mail_Data .= "bla bla bla bla <br> \n";
                 $mail_Data .= "Etc.<br> \n";
                 $mail_Data .= "</body> \n";
                 $mail_Data .= "</HTML> \n";
              
                 $headers  = "MIME-Version: 1.0 \n";
                 $headers .= "Content-type: text/html; charset=iso-8859-1 \n";
                 $headers .= "From: $from  \n";
                 $headers .= "Disposition-Notification-To: $from  \n";
              
                 // Message de Priorité haute
                 // -------------------------
                 $headers .= "X-Priority: 1  \n";
                 $headers .= "X-MSMail-Priority: High \n";
              
                 $CR_Mail = TRUE;
              
                 $CR_Mail = @mail ($to, $Subject, $mail_Data, $headers);
               
                 if ($CR_Mail === FALSE)   echo " ### CR_Mail=$CR_Mail - Erreur envoi mail <br> \n";
                 else                      echo " *** CR_Mail=$CR_Mail - Mail envoyé<br> \n";  
              
              0
              1. pourquoi ne pas t'orienter vers la classe phpmailher ?
                0
                1. si ça peut t'aider j'ai fait
                  http://www.commentcamarche.net/forum/affich-28118589-fonction-mail-ovh

                  donc ça vient forcément de chez eux
                  0
                  1. salut, je viens de faire l'essai sur mon hébergement ovh mutualisé avec ton script et je reçoit bien le mail avec demande d'accusé de réception.
                    et j'ai la réponse de l'echo *** CR_Mail=1 - Mail envoyé
                    <?php 
                    //ATTENTION as tu bien mis le tag php complet comme ci dessus ??
                    
                    // Test fonction mail();
                    
                       // *** A configurer
                    
                       $to    = "monmail@laposte.net";  
                       $from  = "postmaster@monsite.com";     // adresse MAIL OVH liée à ton hébergement.
                    
                       // *** Laisser tel quel
                    
                       $JOUR  = date("Y-m-d");
                       $HEURE = date("H:i");
                    
                       $Subject = "Test Mail - $JOUR $HEURE";
                    
                       $mail_Data = "";
                       $mail_Data .= "<html> \n";
                       $mail_Data .= "<head> \n";
                       $mail_Data .= "<title> Subject </title> \n";
                       $mail_Data .= "</head> \n";
                       $mail_Data .= "<body> \n";
                    
                       $mail_Data .= "Mail HTML simple  : <font color=red> <b>$Subject </b> </font>  <br> \n";
                       $mail_Data .= "<br> \n";
                       $mail_Data .= "bla bla bla bla <br> \n";
                       $mail_Data .= "Etc.<br> \n";
                       $mail_Data .= "</body> \n";
                       $mail_Data .= "</HTML> \n";
                    
                       $headers  = "MIME-Version: 1.0 \n";
                       $headers .= "Content-type: text/html; charset=iso-8859-1 \n";
                       $headers .= "From: $from  \n";
                       $headers .= "Disposition-Notification-To: $from  \n";
                    
                       // Message de Priorité haute
                       // -------------------------
                       $headers .= "X-Priority: 1  \n";
                       $headers .= "X-MSMail-Priority: High \n";
                    
                       $CR_Mail = TRUE;
                    
                       $CR_Mail = @mail ($to, $Subject, $mail_Data, $headers);
                     
                       if ($CR_Mail === FALSE)   echo " ### CR_Mail=$CR_Mail - Erreur envoi mail <br> \n";
                       else                      echo " *** CR_Mail=$CR_Mail - Mail envoyé<br> \n";  
                    
                    ?>
                    0
                    1. Re,
                      Pour ceux qui ont OVH mutualisé perso la première offre la fonction mail() n'est pas disponible.

                      Il faut choisir une autre offre.
                      Voila =)
                      0