envoi d'email en php

Par ledevelopeur58, il y a 10 ans


Bonjour,

Voila ; le doit programmer un envoi d'email avec php, d'habitude je travail avec wamp serveur mais un petit probleme m'empeche de connecter depuis un autre périférique, enfin bref sur wamp serveur j'y arriver a envoyer ses emails, mais j'ai du changer pour Uwamp qui régle le problème ci-dessus. Mais je ne sais pas quel fichier modifier ducoup pour envoyer des email en php avec ce logiciel.

Voici le code php que j'utilise pour envoyer des mails

<?php if(isset($_POST['mailform'])) $header="MIME-Version: 1.0\r\n"; $header='From:"Test.com"<support@test.com>'."\n"; $header.='Content-Type:text/html; charset="uft-8"'."\n"; $header.='Content-Transfer-Encoding: 8bit'; $message=' <html> <body> <div align="center"> <img src="http://www.primfx.com/mailing/banniere.png"/> <br /> J\'ai envoyé ce mail avec PHP ! <br /> <img src="http://www.primfx.com/mailing/separation.png"/> </div> </body> </html> '; mail("unutilisateur@gmail.com", "Salut tout le monde !", $message, $header); ?> <form method="POST" action=""> <input type="submit" value="Recevoir un mail !" name="mailform"/> </form>

Ce que je veux

Recevoir l'email dans ma boite mail.

Ce que j'obtiens

Warning: mail(): 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:\UwAmp\www\Envoimail PHP\index.php on line 23

25 réponses

ledevelopeur58, il y a 10 ans

finalement j'ai trouver la solution tout marche niquel, il faut copier le contenue du php.ini sur le php_uwamp.ini car les ligne de code ne sont les même cela ne cause pas d'erreur. probleme résolue

Carouge10, il y a 10 ans

Bonjour,
Ajouter ceci en début de code en le remplissant:

ini_set("SMTP","smtp.example.com" );

De plus il manque les accolades au if et le 1er $headers var être remplacer par la second car il manque un concaténation

ledevelopeur58, il y a 10 ans

a la place de smtp.exemple il mettre quoi ?

Carouge10, il y a 10 ans

le stmp de votre FAI (free, orange, sfr...)

ledevelopeur58, il y a 10 ans

on peut mette google ?car il me semble que sur wamp serveur cela marche

Carouge10, il y a 10 ans

oui, il en faut un, alors faut tester

ledevelopeur58, il y a 10 ans
<?php ini_set("google","smtp.google.com" ); if(isset($_POST['mailform'])) { $header="MIME-Version: 1.0"."\r\n"; $header='From:"PrimFX.com"<support@primfx.com>'."\n"; $header.='Content-Type:text/html; charset="uft-8"'."\n"; $header.='Content-Transfer-Encoding: 8bit'; $message=' <html> <body> <div align="center"> <img src="http://www.primfx.com/mailing/banniere.png"/> <br /> J\'ai envoyé ce mail avec PHP ! <br /> <img src="http://www.primfx.com/mailing/separation.png"/> </div> </body> </html> '; mail("unutilisateur@gmail.com", "Salut tout le monde !", $message, $header); } ?> <form method="POST" action=""> <input type="submit" value="Recevoir un mail !" name="mailform"/> </form>

toujour une erreur

Carouge10, il y a 10 ans

la même erreur ?

ledevelopeur58, il y a 10 ans

oui mais je pense que l'erreur doit peut etre venir des fichier du logiciel car wamp serveur, il fallait modifier un fichier et dans celui ci je ne trouve pas les ligne a modifier. je ne trouve pas le php.ini

ledevelopeur58, il y a 10 ans

je ne voit que ses ligne la a modifier avec Uwamp

[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = me@example.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path ;sendmail_path =

moi je suis sur win x64 mais je pense que cela ne pose pas de pbl, mais du coup je pense changer les lignes comme suit :

[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 597 // celui de google ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = monadresse@gmail.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path ;sendmail_path =

a savoir que j ai aussi mis sendmail dans le fichier source de Uwamp

Carouge10, il y a 10 ans

le smtp n'est pas localhost mais smtp.google.com

arnich, il y a 10 ans

C'est pas ini_set("google","smtp.google.com" ); mais ini_set("SMTP","smtp.google.com" );

ledevelopeur58, il y a 10 ans

toujour pas je ne voit pas d'ou vient le probleme;

[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = smtp.google.com ; http://php.net/smtp-port smtp_port = 597 ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = unutilisateur@gmail.com <?php ini_set("SMTP","smtp.google.com" ); if(isset($_POST['mailform'])) { $header="MIME-Version: 1.0"."\r\n"; $header='From:"PrimFX.com"<support@primfx.com>'."\n"; $header.='Content-Type:text/html; charset="uft-8"'."\n"; $header.='Content-Transfer-Encoding: 8bit'; $message=' <html> <body> <div align="center"> <img src="http://www.primfx.com/mailing/banniere.png"/> <br /> J\'ai envoyé ce mail avec PHP ! <br /> <img src="http://www.primfx.com/mailing/separation.png"/> </div> </body> </html> '; mail("unutilisateur@gmail.com", "Salut tout le monde !", $message, $header); } ?> <form method="POST" action=""> <input type="submit" value="Recevoir un mail !" name="mailform"/> </form>
Carouge10, il y a 10 ans

l'erreur à du changer. L'erreur affiche toujours un pb avec localhost ?

ledevelopeur58, il y a 10 ans

Warning: mail(): Failed to connect to mailserver at "smtp.google.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\UwAmp\www\Envoimail PHP\index.php on line 24

ledevelopeur58, il y a 10 ans

Warning: mail(): Failed to connect to mailserver at "smtp.google.com" port 597, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\UwAmp\www\Envoimail PHP\index.php on line 24

Carouge10, il y a 10 ans

essayer avec le smtp de votre fai

Carouge10, il y a 10 ans

et smtp.google.com n'existe pas.
c'est smtp.gmail.com

ledevelopeur58, il y a 10 ans

Cette fois sa change quelque chose il met plus de temp a afficher l'erreur donc il doit commencer a i arriver mais il y a toujour un problème.
Warning: mail(): Failed to connect to mailserver at "smtp.gmail.com" port 597, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\UwAmp\www\Envoimail PHP\index.php on line 24

ledevelopeur58, il y a 10 ans
[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = smtp.gmail.com ; http://php.net/smtp-port smtp_port = 597 ; For Win32 only. ; http://php.net/sendmail-from sendmail_from = unutilisateur@gmail.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path ;sendmail_path = <?php ini_set("SMTP","smtp.gmail.com" ); if(isset($_POST['mailform'])) { $header="MIME-Version: 1.0"."\r\n"; $header='From:"PrimFX.com"<support@primfx.com>'."\n"; $header.='Content-Type:text/html; charset="uft-8"'."\n"; $header.='Content-Transfer-Encoding: 8bit'; $message=' <html> <body> <div align="center"> <img src="http://www.primfx.com/mailing/banniere.png"/> <br /> J\'ai envoyé ce mail avec PHP ! <br /> <img src="http://www.primfx.com/mailing/separation.png"/> </div> </body> </html> '; mail("unutilisateur@gmail.com", "Salut tout le monde !", $message, $header); } ?> <form method="POST" action=""> <input type="submit" value="Recevoir un mail !" name="mailform"/> </form>
Carouge10, il y a 10 ans

et avec le smtp de votre fai ?

Lartak, il y a 10 ans

Bonjour.
Si tu utilises un SMTP autre que celui en local, il te faut spécifier un mot de passe.

ledevelopeur58, il y a 10 ans

le truc c'est que personne n'a fait de tuto sur ce logiciel et donc trouver la solution est un peut complique et je ne voit pas je ou pourrait specifier un mdp

ledevelopeur58, il y a 10 ans

Le Probleme avec Uwamp (http://www.uwamp.com/fr/) c'est que je n'arrive pas a trouver le php.ini la seul qui y ressemble le plus c'est : ce code la ;

[mail function] ; For Win32 only. ; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 597 // celui de google ; For Win32 only. ; http://php.net/sendmail-from ;sendmail_from = monadresse@gmail.com ; For Unix only. You may supply arguments as well (default: "sendmail -t -i"). ; http://php.net/sendmail-path ;sendmail_path =