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
Auteur
Réponse acceptée

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

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

a la place de smtp.exemple il mettre quoi ?

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

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

oui, il en faut un, alors faut tester

<?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

la même erreur ?

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

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

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

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

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>

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

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

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

essayer avec le smtp de votre fai

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

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

[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>

et avec le smtp de votre fai ?

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

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

le truc c'est que personne n'a fait de tuto sur ce logiciel

Tu pourrais peut-être t'inspirer de ceci pour trouver une solution : Blog » Envoyer des mails en local avec Wamp.

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 =