Partage
  • Partager sur Facebook
  • Partager sur Twitter

Problème d'envoi de mails avec Wampserver

    4 mars 2021 à 13:35:41

    Bonjour, 

    Je souhaite envoyer un mail (en localhost) en PHP avec le logiciel Wampserver. J'ai inclus sendmail dans mon serveur Wamp. Je souhaite utiliser Gmail comme serveur expéditeur. Cependant, je n'arrive pas à envoyer de mails. J'ai déjà utilisé sendmail dans des projets antérieurs et cela fonctionnait. J'ai essayé d'utiliser un serveur de type Microsoft pour faire un test mais le résultat est identique. Auriez-vous une piste à me donner? Pour vous éclairer, je vous laisser mes codes.

    Voici le code de la partie mail function dans php.ini:

    [mail function]
    ; For Win32 only.
    ; http://php.net/smtp
    ;SMTP = smtp.gmail.com
    ; http://php.net/smtp-port
    ;smtp_port = 587
    
    ; For Win32 only.
    ; http://php.net/sendmail-from
    ;sendmail_from ="***@gmail.com
    
    ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
    ; http://php.net/sendmail-path
    sendmail_path = "C:\wamp\sendmail\sendmail.exe -t -i"

    Voici le code utilisé pour sendmail.ini:

    ; configuration for fake sendmail
    
    ; if this file doesn't exist, sendmail.exe will look for the settings in
    ; the registry, under HKLM\Software\Sendmail
    
    [sendmail]
    
    ; you must change mail.mydomain.com to your smtp server,
    ; or to IIS's "pickup" directory.  (generally C:\Inetpub\mailroot\Pickup)
    ; emails delivered via IIS's pickup directory cause sendmail to
    ; run quicker, but you won't get error messages back to the calling
    ; application.
    
    smtp_server=smtp.gmail.com
    
    ; smtp port (normally 25)
    
    smtp_port=587
    
    ; SMTPS (SSL) support
    ;   auto = use SSL for port 465, otherwise try to use TLS
    ;   ssl  = alway use SSL
    ;   tls  = always use TLS
    ;   none = never try to use SSL
    
    smtp_ssl=auto
    
    ; the default domain for this server will be read from the registry
    ; this will be appended to email addresses when one isn't provided
    ; if you want to override the value in the registry, uncomment and modify
    
    default_domain=localhost
    
    ; log smtp errors to error.log (defaults to same directory as sendmail.exe)
    ; uncomment to enable logging
    
    error_logfile=error.log
    
    ; create debug log as debug.log (defaults to same directory as sendmail.exe)
    ; uncomment to enable debugging
    
    debug_logfile=debug.log
    
    ; if your smtp server requires authentication, modify the following two lines
    
    auth_username=***@gmail.com
    auth_password=password
    
    ; if your smtp server uses pop3 before smtp authentication, modify the 
    ; following three lines.  do not enable unless it is required.
    
    ;pop3_server=
    ;pop3_username=
    ;pop3_password=
    
    ; force the sender to always be the following email address
    ; this will only affect the "MAIL FROM" command, it won't modify 
    ; the "From: " header of the message content
    
    force_sender=***@gmail.com
    
    ; force the sender to always be the following email address
    ; this will only affect the "RCTP TO" command, it won't modify 
    ; the "To: " header of the message content
    
    ;force_recipient=
    
    ; sendmail will use your hostname and your default_domain in the ehlo/helo
    ; smtp greeting.  you can manually set the ehlo/helo name if required
    
    hostname=localhost
    
    

    Voici le code de ma page sendmail.php. Cette page sert à envoyer un mail test.

    <?php
      $dest = "***@hotmail.com";
      $sujet = "Email de test";
      $corp = "Salut! Ceci est un email de test envoyer par un script PHP";
      $headers = "From: ***@gmail.com";
    
      if (mail($dest, $sujet, $corp, $headers)) {
        echo "Email envoyé avec succès à $dest ...";
      } else {
        echo "Échec de l'envoi de l'email...";
      }
    ?>

    Lorsque j'exécute la page sendmail.php, on m'indique que mon mail est bien envoyé mais rien n'apparaît dans la liste des messages envoyés de Gmail et rien n'apparaît dans la boite de réception du destinataire.

    J'ai regardé les logs (error.log) et rien n'apparaît dans le fichier.

    Pour information, j'utilise PHP 5.6.40 et Wampserver 3.2.3.3

    Je vous souhaite une bonne journée ! ;)

    • Partager sur Facebook
    • Partager sur Twitter

    Problème d'envoi de mails avec Wampserver

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown