IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

problême avec PHPmailer


Sujet :

Langage PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    9
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 9
    Par défaut problême avec PHPmailer
    Bonjour,à tous, j'ai un soucis avec php mailer.

    je m'explique,
    j'ai fais un site internet, depuis ce site, j'ai fais un formulaire pour que l'utilisateur m'envois un mail via phpmailer et mon smtp ovh.

    pour les adeptes, je vous met les 200 premières lignes de ma class phpmailer
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
     
    <?php
    ////////////////////////////////////////////////////
    // PHPMailer - PHP email class
    //
    // Class for sending email using either
    // sendmail, PHP mail(), or SMTP.  Methods are
    // based upon the standard AspEmail(tm) classes.
    //
    // Copyright (C) 2001 - 2003  Brent R. Matzelle
    //
    // License: LGPL, see LICENSE
    ////////////////////////////////////////////////////
     
    /**
     * PHPMailer - PHP email transport class
     * @package PHPMailer
     * @author Brent R. Matzelle
     * @copyright 2001 - 2003 Brent R. Matzelle
     */
    class PHPMailer
    {
        /////////////////////////////////////////////////
        // PUBLIC VARIABLES
        /////////////////////////////////////////////////
     
        /**
         * Email priority (1 = High, 3 = Normal, 5 = low).
         * @var int
         */
        var $Priority          = 3;
     
        /**
         * Sets the CharSet of the message.
         * @var string
         */
        var $CharSet           = "iso-8859-1";
     
        /**
         * Sets the Content-type of the message.
         * @var string
         */
        var $ContentType        = "text/plain";
     
        /**
         * Sets the Encoding of the message. Options for this are "8bit",
         * "7bit", "binary", "base64", and "quoted-printable".
         * @var string
         */
        var $Encoding          = "8bit";
     
        /**
         * Holds the most recent mailer error message.
         * @var string
         */
        var $ErrorInfo         = "";
     
        /**
         * Sets the From email address for the message.
         * @var string
         */
        var $From               = "postmaster@***.fr";
     
        /**
         * Sets the From name of the message.
         * @var string
         */
        var $FromName           = "***";
     
        /**
         * Sets the Sender email (Return-Path) of the message.  If not empty,
         * will be sent via -f to sendmail or as 'MAIL FROM' in smtp mode.
         * @var string
         */
        var $Sender            = "";
     
        /**
         * Sets the Subject of the message.
         * @var string
         */
        var $Subject           = "";
     
        /**
         * Sets the Body of the message.  This can be either an HTML or text body.
         * If HTML then run IsHTML(true).
         * @var string
         */
        var $Body               = "";
     
        /**
         * Sets the text-only body of the message.  This automatically sets the
         * email to multipart/alternative.  This body can be read by mail
         * clients that do not have HTML email capability such as mutt. Clients
         * that can read HTML will view the normal Body.
         * @var string
         */
        var $AltBody           = "";
     
        /**
         * Sets word wrapping on the body of the message to a given number of 
         * characters.
         * @var int
         */
        var $WordWrap          = 0;
     
        /**
         * Method to send mail: ("mail", "sendmail", or "smtp").
         * @var string
         */
        var $Mailer            = "mail";
     
        /**
         * Sets the path of the sendmail program.
         * @var string
         */
        var $Sendmail          = "/usr/sbin/sendmail";
     
        /**
         * Path to PHPMailer plugins.  This is now only useful if the SMTP class 
         * is in a different directory than the PHP include path.  
         * @var string
         */
        var $PluginDir         = "";
     
        /**
         *  Holds PHPMailer version.
         *  @var string
         */
        var $Version           = "1.71";
     
        /**
         * Sets the email address that a reading confirmation will be sent.
         * @var string
         */
        var $ConfirmReadingTo  = "";
     
        /**
         *  Sets the hostname to use in Message-Id and Received headers
         *  and as default HELO string. If empty, the value returned
         *  by SERVER_NAME is used or 'localhost.localdomain'.
         *  @var string
         */
        var $Hostname          = "";
     
     
        /////////////////////////////////////////////////
        // SMTP VARIABLES
        /////////////////////////////////////////////////
     
        /**
         *  Sets the SMTP hosts.  All hosts must be separated by a
         *  semicolon.  You can also specify a different port
         *  for each host by using this format: [hostname:port]
         *  (e.g. "smtp1.example.com:25;smtp2.example.com").
         *  Hosts will be tried in order.
         *  @var string
         */
        var $Host        = "localhost";
     
        /**
         *  Sets the default SMTP server port.
         *  @var int
         */
        var $Port        = 465;
     
        /**
         *  Sets the SMTP HELO of the message (Default is $Hostname).
         *  @var string
         */
        var $Helo        = "";
     
        /**
         *  Sets SMTP authentication. Utilizes the Username and Password variables.
         *  @var bool
         */
        var $SMTPAuth     = false;
     
        /**
         *  Sets SMTP username.
         *  @var string
         */
        var $Username     = "";
     
        /**
         *  Sets SMTP password.
         *  @var string
         */
        var $Password     = "";
     
        /**
         *  Sets the SMTP server timeout in seconds. This function will not 
         *  work with the win32 version.
         *  @var int
         */
        var $Timeout      = 10;
     
        /**
         *  Sets SMTP class debugging on or off.
         *  @var bool
         */
     
    ?>
    les premières de ma class smtp

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
     
    <?php
    ////////////////////////////////////////////////////
    // SMTP - PHP SMTP class
    //
    // Version 1.02
    //
    // Define an SMTP class that can be used to connect
    // and communicate with any SMTP server. It implements
    // all the SMTP functions defined in RFC821 except TURN.
    //
    // Author: Chris Ryan
    //
    // License: LGPL, see LICENSE
    ////////////////////////////////////////////////////
     
    /**
     * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
     * commands except TURN which will always return a not implemented
     * error. SMTP also provides some utility methods for sending mail
     * to an SMTP server.
     * @package PHPMailer
     * @author Chris Ryan
     */
    class SMTP
    {
        /**
         *  SMTP server port
         *  @var int
         */
        var $SMTP_PORT = 465;
     
        /**
         *  SMTP reply line ending
         *  @var string
         */
        var $CRLF = "\r\n";
     
        /**
         *  Sets whether debugging is turned on
         *  @var bool
         */
        var $do_debug;       # the level of debug to perform
     
        /**#@+
         * @access private
         */
        var $smtp_conn;      # the socket to the server
        var $error;          # error if any on the last call
        var $helo_rply;      # the reply the server sent to us for HELO
        /**#@-*/
     
        /**
         * Initialize the class so that the data is in a known state.
         * @access public
         * @return void
         */
        function SMTP() {
            $this->smtp_conn = 0;
            $this->error = null;
            $this->helo_rply = null;
     
            $this->do_debug = 0;
        }
     
    ?>
    et enfin ma page envoi.php

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
     
    <?php
    session_start();
    require "phpmailer/class.phpmailer.php";
    $nomsociete			=	$_SESSION['nomsociete'];
    $nom				=	$_SESSION['nom'];
    $prenom				=	$_SESSION['prenom'];
     
    $mail1				=	$_SESSION['mail'];
    $tel				=	$_SESSION['tel'];
    $sujet				=	$_SESSION['sujet'];
    $message			=	$_SESSION['message'];
     
    $mail = new PHPmailer();
    $mail->SetLanguage("en", "phpmailer/language/"); 
    $mail->IsSMTP();
    $mail->IsHTML(true);
     
    $mail->Host="ssl0.ovh.net";
    	$mail->SMTPAuth = true;
    	$mail->Username="postmaster@******.fr";
    	$mail->Password="********";
     
    $mail->From="$mail1";
    $mail->AddAddress('monadresse@gmail.com');
    $mail->AddReplyTo('$mail1');	
    $mail->Subject='$sujet';	
    $mail->Body='
    	<html>		
    	</head>
    	<body>
    	<h2>Message provenant du site SlyProd</h2>		
    	<p>'.$sujet.'</p>
    	<p>Nom de ma société:'.$nomsociete.'</p>
    	<p>je m\'appelle '.$nom.' '.$prenom.', on peu me joindre au '.$tel.' et mon message est le suivant<p>
    	<p>'.$message.'</p>
    	</body>
    	</html>';	
     
    	if(!$mail->Send())
    	{ 
    	  echo "<p>tu es la</p>";	
    	  echo $mail->ErrorInfo;
     
     
    	}
    	else{	  
    	  echo "<p>Mail envoyé avec succès à moi</p>";
    	}
    	$mail->SmtpClose();
    	unset($mail);
    ?>
    J'obtiens : "The following From address failed: "

    Quelqun'un peut m'aider?

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    D'apres l'erreur il semble que $_SESSION['mail'] soit vide.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    9
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 9
    Par défaut
    je viens de faire une vérification (que j'ai laissé d ailleur) $_SESSION['mail'] n'est pas vide

    http://slyprod.fr/slyprod/index.php?page=contact1

  4. #4
    Membre Expert Avatar de nosferapti
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    1 157
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 1 157
    Par défaut
    essaye de faire ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $mail->Host = 'ssl://ssl0.ovh.net:465';

  5. #5
    Membre habitué
    Profil pro
    Inscrit en
    Mars 2008
    Messages
    9
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2008
    Messages : 9
    Par défaut
    Citation Envoyé par nosferapti Voir le message
    essaye de faire ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $mail->Host = 'ssl://ssl0.ovh.net:465';

    j ai un message d'érreur

    Warning: fsockopen() expects parameter 2 to be long, string given in /homez.323/slyprod/www/slyprod/class.smtp.php on line 122

    tu es la

    SMTP Error: Could not connect to SMTP host.


    voila le code qui correspond
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    #connect to the smtp server
        $this->smtp_conn = fsockopen($host,    # the host of the server
                                     $port,    # the port to use
                                     $errno,   # error number if any
                                     $errstr,  # error message if any
                                     $tval);   # give up after ? secs
    la ligne 122 est: $tval); # give up after ? secs

Discussions similaires

  1. Problème avec PHPMailer
    Par abc.xyz dans le forum Langage
    Réponses: 27
    Dernier message: 03/07/2015, 11h22
  2. Problème avec phpmailer boucle
    Par tidou95220 dans le forum Langage
    Réponses: 2
    Dernier message: 26/10/2011, 19h10
  3. Problème avec PHPMAILER
    Par GeantBioHazard dans le forum Langage
    Réponses: 2
    Dernier message: 11/06/2008, 11h36
  4. [PHPMailer] Problème avec phpmailer
    Par Arkoze dans le forum Bibliothèques et frameworks
    Réponses: 11
    Dernier message: 08/02/2007, 17h47
  5. [PHPMailer] problème avec la classe phpmailer
    Par sansouna24 dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 08/04/2006, 17h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo