Le mail de confirmation ne s'envoie pas...

Skill_DuTigre

Skill_DuTigre Le 28 août 2016 à 15:40 (Édité le 25 janvier 2019 à 17:52)

Hello !

(Ce topic n'a aucun rapport avec le tuto de Boris)

Je suis en train de faire un site, et pour la partie inscription, j'ai un problème...
Je souhaite envoyer un mail de confirmation, je n'ai aucune erreur et même le message "Un email vous a été envoyer" etc... Mais je ne reçois pas le mail... 

Code : 

<?php
require('config/bdd.php');
require('includes/functions.php');
require('config/constants.php');
if(isset($_POST['register'])) {
  if(not_empty(['name', 'pseudo', 'email', 'password', 'password_confirm'])) {
  
// toutes les vérifications...
 
    if(count($errors) == 0) {
      $to = $email;
      $subject = WEBSITE_NAME. " - Activation de compte";
      $token = sha1($pseudo.$email.$password);
      ob_start();
      require('templates/emails/activation.tmpl.php');
      $content = ob_get_clean();
      $headers = 'MIME-Version: 1.0' . "\r\n";
      $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
      mail($to, $subject, $content, $headers, "From: mail@web.com");
      echo "Mail d'activation envoyé !";
    }
  } else {
      $errors[] = "Veuillez remplir tous les champs.";
  }
}
require('views/register.view.php');
?>
J'ai essayer avec un hébergement Hostinger. 

Vous voyez une erreur ? 😀
Balatharas

Balatharas Le 28 août 2016 à 19:45

Sendmail désactivé sur Hostinger ?
lecteursdb

lecteursdb Le 29 août 2016 à 18:41

Salut ! 

j'avais eu le même problème quand je construisais mon mini réseau social...eh bien il m'avait été dit que la fonction mail de php est très instable sur certains serveurs...et pour y remédier j'ai utilisé PhpMailer et tout a fonctionné...donc je te conseillerais la même chose 😉 
TheOldNoob

TheOldNoob Le 30 août 2016 à 01:18

Salut,

Lecteursdb a raison, phpmailer est le plus simple et le plus passe partout 😀
kinginventeur

kinginventeur Le 11 septembre 2016 à 02:34

// Tout est dis 😀
http://www.glob.com.au/sendmail/sendmail.zip

le problème était que sendmail ne s'exécutait pas en tant qu'administrateur, maintenant j'envoie mes messages tranquillement sans problème
- un clic droit sur sendmail.exe
- Propriétés
-Compatibilité
- Modifiez la configuration pour tous les utilisateurs
- Exécuter en tant que Windows XP SP 3
- cocher Exécuté en tant qu'administrateur
-cliquer avec joie sur OK 😀
voici mon fichier 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"
et voici le fichier 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=587
; 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=gmail.com
; 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= ***********
; 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=
// Si tu as une question pose la ^^
tutosfaciles48

tutosfaciles48 Le 18 septembre 2016 à 15:31

Bonjour, fait une vérification sur la fonction mail:
if(mail(...)) {
   //dire mail envoyé
} else {
   //mail non envoyé
}
Profil introuvable

Profil introuvable Le 3 octobre 2016 à 19:34

Et met le topic en résolu si tu as fini 😉
tutosfaciles48

tutosfaciles48 Le 16 octobre 2016 à 14:46

Ah oui: si tu a plusieurs headers (ton cas) met des points égal (les signes)
 $header .= etc;
Vous devez être connecté pour poster une réponse. Se connecter ou Créer un compte