La fonction mail() ne parvient pas à fonctionner
Posté : 17 juin 2017, 02:39
Bonjour à toutes et à tous,
J'essai à l'inscription d'un membre, de vérifier pour le moment si un lien d'activation s'envoit bien à une adresse indiquée, mais j'ai l'erreur suivante :
Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp64\www\projet\views\register.php on line 34
Et je ne parviens à réparer mon erreur bien que cette erreur soit courante...
Voici mon code:
Le fichier php.ini
Mon fichier sendmail.ini
Quelqu'un pour m'aider s'il vous plaît ?
J'essai à l'inscription d'un membre, de vérifier pour le moment si un lien d'activation s'envoit bien à une adresse indiquée, mais j'ai l'erreur suivante :
Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp64\www\projet\views\register.php on line 34
Et je ne parviens à réparer mon erreur bien que cette erreur soit courante...
Voici mon code:
Le fichier php.ini
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = "[email protected]"
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\wamp64\sendmail\sendmail.exe" -t"
Mon fichier sendmail.ini
smtp_server=smtp.gmail.com
; smtp port (normally 25)
smtp_port=25
; 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=mydomain.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
[email protected]
auth_password=mon mot de passe
Mon bout de code permettant l'envoi de l'email :[...]
if(count($errors)== 0){
$to = $email;
$subject = WEBSITENAME. " - ACTIVATION DE COMPTE";
$token = sha1($nom.$email.$mdp);
ob_start();
require('templates/emails/active.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);
echo "Un mail d'activation vous a été envoyé.";
}
[...]
Quelqu'un pour m'aider s'il vous plaît ?