Bonjour,

Mon souhait, depuis mon appli php localhost envoyer à des destinataires des fichiers excel suite à requête de ma bdd phpmyadmin.

Mon point bloquant se situe actuellement au niveau du server SMTP

faut-il s incrire chez free ? c gratuit comment faire faut-il absolument avoir un server smtp si oui comment faire dans mon cas svp ? car je souhairais rester en loacalhost svp

VOICI LE MESSAGE D ERREUR qui peu me corriger svp ?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
require_once('phpmailer/class.phpmailer.php');
 
$mail = new PHPMailer();
 
$mail->IsSMTP(); // telling the class to use SMTP
try {
        $mail->Host          = ("smtp.xxx.fr");
        $mail->SMTPAuth      = true;                  // enable SMTP authentication
        $mail->SMTPKeepAlive = true;                  // SMTP connection will not close after each email sent
        $mail->Port          = 5027;                    // set the SMTP port for the GMAIL server
        $mail->Username      = ("smtp%xxx.fr"); // SMTP account username
        $mail->Password      = ("xxx");        // SMTP account password
} catch (phpmailerException $e) {
        echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
        echo $e->getMessage(); //Boring error messages from anything else!
}
$user = "xxx";
$password = "xxx";
$database = "xxxx";
$host = "xxx";
 
$connect = mysql_connect($host, $user, $password) or die(mysql_error());
    mysql_select_db($database);
 
$forcli = $Cookcli;
$result = mysql_query ("select * from client where codecli = '$forcli'");
$row = mysql_fetch_object($result);
 
echo "<FONT SIZE=+3>";
echo "<DIV ALIGN=center><FONT COLOR=\"#0000CC\"><B>$forcli           $row->nom</B></FONT></DIV>";
echo "</FONT>";
echo "<HR SIZE=3 NOSHADE>";
 
$forcli = $Cookcli;
$fornom = $Cooknom;
if ($forcli < 1)
   {echo "<B><FONT SIZE=+1>Votre session est terminée, vous devez vous identifier à nouveau...</FONT></B>";}
 
$fordate = gmdate("Y-m-d");
$nb = 1;
if ($forcli < 1) {$nb = 0;}
 
 $result = mysql_query("select * from bordereau left join dossier on dossier.numdos = bordereau.numdos where  bordereau.numbor = '$numbor' and bordereau.etat = 1
        order by bordereau.numbor, bordereau.numdos ");
 
$nb2 = 0;
if ($result) {$nb2 = mysql_num_rows($result);}
if ($nb2 == 0) {$nb = 0;}
if ($nb > 0)
   {while ($row = mysql_fetch_object($result))
          {
          $si = " numbor = $row->numbor and numdos = $row->numdos ";
          $majbor = mysql_query
                          ("update bordereau set etat = 2 where ".$si);
          $mesbor .= "$forcli $row->typetrans $fornom;$row->numdos;";   
          $mesbor .= "$row->reference;$row->nom;$row->adresse1;$row->adresse2;";
          $mesbor .= "$row->codepostal;$row->ville;$row->codepays;";
          $mesbor .= "$row->nbcolis;$row->poids;$row->volume;$row->metreplancher;";
          $mesbor .= "$row->portdu;$row->cr;$row->crdevise;";
          $mesbor .= "$row->cr2;$row->crdev2;";
          $mesbor .= "$row->vd;$row->vddevise;$row->commentaire;";
          $mesbor .= "$row->express;$row->hayon;$row->teldesti;";
          $mesbor .= "$row->nbpalettes;$row->obspalette;\n";
          }
        ;}
$mesbor = strtoupper($mesbor);
$ligne1 = "<br>";
$ligne2 = "<br>le bordereau numéro <B>$numbor</B> est transmis";
if ($nb > 0) {
        echo "$ligne1 $ligne2";
        try {
 
                $mail->  SetFrom =("contact@xxx.fr<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>");
                $mail->  AddReplyTo =("contact@xxx.fr<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>;");
                $mail->  Subject = ("Bordereau de chargement N $numbor");
                $mail->  message = ("$mesbor");
                $mail->  AddAdress = ('contact@xxx.fr<script type="text/javascript">
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */
</script>');
                $mail->  AltBody = $mesbor;
                $mail->AddAttachment("BO$numbor.txt");
                $mail->Send();
        } catch (phpmailerException $e) {
                echo $e->errorMessage(); //Pretty error messages from PHPMailer
        } catch (Exception $e) {
                echo $e->getMessage(); //Boring error messages from anything else!
}
}
 
if ($nb >0)
   {echo "<BR><BR><DIV ALIGN=\"center\">
                 <A HREF=\"borimp.php? numbor=$numbor\" TARGET=_blank>Imprimer le bordereau</A>
                 &nbsp;&nbsp;&nbsp;
                 <A HREF=\"bordefinitif.php\" TARGET=_self>Retour</A>
   </DIV>" ;} 
?>