Bonjour à tous,
je suis actuellement en stage et on me demande de faire un formulaire de contact avec un code déjà fait mais le mail ne s'envoie donc je dois trouver l'erreur sauf qu'il n'y en à pas, pour moi le code est bon donc merci d'avance pour vos réponses.
[code=html][/<?php require('./send-mail.php') ?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
>
<title>Feedback form</title>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css"
>
<link
rel="stylesheet"
type="text/css"
href="css/style.css"
/>
</head>
<body>
<header>
<h2>"Partagez vos news"</h2>
<img
id="logo"
src="images/exagroup.png"
alt="exaprint"
>
</header>
<div class="container mt-3">
<form
role="form"
method="POST"
action="index.php"
name="formNews"
enctype="multipart/form-data"
>
<div class="row">
<label for="atelier">Atelier *</label>
<input
type="text"
class="form-control"
name="atelier"
id="atelier"
placeholder="Champ obligatoire"
required
>
</div>
<div class="row">
<label for="NomPrenom">NOM Prénom *</label>
<input
type="text"
class="form-control"
name="NomPrenom"
id="NomPrenom"
placeholder="Champ obligatoire"
required
>
</div>
<div class="row">
<label for="news">News *</label>
<textarea
rows="6"
class="form-control"
name="news"
id="news"
placeholder="Votre news"
required
></textarea>
</div>
<div class="row">
<label for="file">Photo *</label><br/>
<img
id="photo"
src="images/photo.png"
alt="Photo"
>
<input
type="file"
accept="image/*"
name="image"
id="file"
required
>
</div>
<div class="row">
<input
type="submit"
value="? Envoyer la news"
class="btn btn-md btn-success"
>
</div>
</form>
</div>
<script
type="text/javascript"
src="http://code.jquery.com/jquery-2.1.4.min.js"
></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</body>
</html>]
[code=php][/<?php
if (isset($_POST["atelier"]) && $_POST["atelier"] != "") {
if (isset($_POST["NomPrenom"]) && $_POST["NomPrenom"] != "") {
if (isset($_POST["news"]) && $_POST["news"] != "") {
if (isset($_FILES["image"]["error"]) && $_FILES["image"]["error"] == "0") {
$atelier = $_POST["atelier"];
$nomPrenom = $_POST["NomPrenom"];
$news = $_POST["news"];
$id = (list_folder("db")) + 1;
$data = '{"Atelier":"' . $atelier . '","NomPrenom":"' . $nomPrenom . '","News":"' . $news . '","File":"db/' . $id . '-' . $_FILES["image"]["name"] . '"}';
writeJson($id, $data);
move_uploaded_file($_FILES["image"]["tmp_name"], "./files/" . $id . "-" . $_FILES["image"]["name"]);
$bodyTmp = "<strong>$nomPrenom, ($atelier):</strong><br/><br/>$news<br/><br/> <a href='http://94.103.141.152/appli/amlie/news/files/" . $id . "-" . $_FILES["image"]["name"] . "'>Fichier attaché</a>";
$mail = ["subject" => "Nouvelle news atelier (" . $id . ")", "body" => $bodyTmp];
getMailSend($mail);
//echo "News postée";
}
}
}
}
function list_folder($filename)
{
$out = null;
if (is_dir($filename)) {
$n = 0;
$d = dir($filename);
while ($entry = $d->read()) {
if ($entry != '.' && $entry != '..' && $entry != '.DS_Store' && $entry != '@eaDir' && $entry != '.HSancillary' && $entry != '.HSxmap') {
$n++;
}
}
$out .= $n;
$d->close();
}
return $out;
}
function writeJson($id, $txt)
{
$filename = "./db/" . $id . ".json";
$handleEnd = fopen($filename, "a+");
chmod($filename, 0777);
fwrite($handleEnd, $txt);
fclose($handleEnd);
}
function getMailSend($mail)
{
$subject = $mail['subject'];
$psBody = $mail['body'];
$to = "amelie.escaffit@exaprint.fr";
$headers = 'From: News ateliers
<amelie.escaffit@exaprint.fr>' . "\r\n" .
'Reply-To: ameliepao@exagroup.biz' . "\r\n" .
'Content-Type: text/html; charset="iso-8859-1"' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$message = '
<html>
<head>
<meta
http-equiv="Content-Type"
content="text/html charset=iso-8859-1"
>
<title>EXAPRINT</title>
</head>
<body
style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"
bgcolor="#E9E9E9"
leftmargin="0"
topmargin="0"
marginwidth="0"
marginheight="0"
>
<div>
<table
width="675"
border="0"
align="center"
cellpadding="0"
cellspacing="0"
>
<tbody>
<tr>
<td
colspan="3"
align="left"
valign="top"
background="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/entete1.jpg"
>
<img
src="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/espaceur.gif"
width="675"
height="108"
alt=""
>
</td>
</tr>
<tr>
<td
rowspan="3"
align="left"
valign="top"
background="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/fd-col-g.png"
>
<img
src="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/deg-col-g.png"
width="20"
height="251"
alt=""
>
</td>
<td bgcolor="#FFFFFF">
<div style="margin:30px; font-family:Arial, Helvetica, sans-serif; font-size:14px">
<span style="font-family: DIN,Trebuchet MS,sans-serif;">
<meta charset="ISO-8859-15"><span style="font-weight: bold;">' . $subject . '</span>
<br>
<br/>
<hr>
' . $psBody . '
<br>
<br>Service de Production
<br><a href="mailto:ameliepao@exagroup.biz">ameliepao@exagroup.biz</a>
</span>
</div>
</td>
<td
rowspan="3"
align="left"
valign="top"
background="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/fd-col-d.png"
>
<img
src="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/deg-col-d.png"
width="20"
height="251"
alt=""
>
</td>
</tr>
<tr>
<td
align="left"
valign="top"
bgcolor="#FFFFFF"
>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">
<a href="http://www.exaprint.fr/">
<img
src="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/exaprint.jpg"
alt=""
width="635"
height="107"
border="0"
>
</a>
</td>
</tr>
<tr>
<td
colspan="3"
align="left"
valign="top"
background="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/bottom.png"
>
<img
src="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/espaceur.gif"
width="675"
height="33"
alt=""
>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>';
$caracterWeb = ["à", "ç", "é", "è", "ô", "À", "É", "È"];
$caracterClean = ["à", "ç", "é", "è", "ô", "À", "É", "È"];
$message = str_replace($caracterWeb, $caracterClean, $message);
if (mail($to, $subject, $message, $headers)) {
echo "Votre news à bien été envoyé";
} else {
echo " <pre>mail NON envoyé à $to -- " . date('H:i:s // d-m-Y') . "</pre>";
echo error_get_last()['message'];
}
}]
Modifié par Skycrim (03 Apr 2019 - 11:09)
je suis actuellement en stage et on me demande de faire un formulaire de contact avec un code déjà fait mais le mail ne s'envoie donc je dois trouver l'erreur sauf qu'il n'y en à pas, pour moi le code est bon donc merci d'avance pour vos réponses.
[code=html][/<?php require('./send-mail.php') ?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
>
<title>Feedback form</title>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css"
>
<link
rel="stylesheet"
type="text/css"
href="css/style.css"
/>
</head>
<body>
<header>
<h2>"Partagez vos news"</h2>
<img
id="logo"
src="images/exagroup.png"
alt="exaprint"
>
</header>
<div class="container mt-3">
<form
role="form"
method="POST"
action="index.php"
name="formNews"
enctype="multipart/form-data"
>
<div class="row">
<label for="atelier">Atelier *</label>
<input
type="text"
class="form-control"
name="atelier"
id="atelier"
placeholder="Champ obligatoire"
required
>
</div>
<div class="row">
<label for="NomPrenom">NOM Prénom *</label>
<input
type="text"
class="form-control"
name="NomPrenom"
id="NomPrenom"
placeholder="Champ obligatoire"
required
>
</div>
<div class="row">
<label for="news">News *</label>
<textarea
rows="6"
class="form-control"
name="news"
id="news"
placeholder="Votre news"
required
></textarea>
</div>
<div class="row">
<label for="file">Photo *</label><br/>
<img
id="photo"
src="images/photo.png"
alt="Photo"
>
<input
type="file"
accept="image/*"
name="image"
id="file"
required
>
</div>
<div class="row">
<input
type="submit"
value="? Envoyer la news"
class="btn btn-md btn-success"
>
</div>
</form>
</div>
<script
type="text/javascript"
src="http://code.jquery.com/jquery-2.1.4.min.js"
></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</body>
</html>]
[code=php][/<?php
if (isset($_POST["atelier"]) && $_POST["atelier"] != "") {
if (isset($_POST["NomPrenom"]) && $_POST["NomPrenom"] != "") {
if (isset($_POST["news"]) && $_POST["news"] != "") {
if (isset($_FILES["image"]["error"]) && $_FILES["image"]["error"] == "0") {
$atelier = $_POST["atelier"];
$nomPrenom = $_POST["NomPrenom"];
$news = $_POST["news"];
$id = (list_folder("db")) + 1;
$data = '{"Atelier":"' . $atelier . '","NomPrenom":"' . $nomPrenom . '","News":"' . $news . '","File":"db/' . $id . '-' . $_FILES["image"]["name"] . '"}';
writeJson($id, $data);
move_uploaded_file($_FILES["image"]["tmp_name"], "./files/" . $id . "-" . $_FILES["image"]["name"]);
$bodyTmp = "<strong>$nomPrenom, ($atelier):</strong><br/><br/>$news<br/><br/> <a href='http://94.103.141.152/appli/amlie/news/files/" . $id . "-" . $_FILES["image"]["name"] . "'>Fichier attaché</a>";
$mail = ["subject" => "Nouvelle news atelier (" . $id . ")", "body" => $bodyTmp];
getMailSend($mail);
//echo "News postée";
}
}
}
}
function list_folder($filename)
{
$out = null;
if (is_dir($filename)) {
$n = 0;
$d = dir($filename);
while ($entry = $d->read()) {
if ($entry != '.' && $entry != '..' && $entry != '.DS_Store' && $entry != '@eaDir' && $entry != '.HSancillary' && $entry != '.HSxmap') {
$n++;
}
}
$out .= $n;
$d->close();
}
return $out;
}
function writeJson($id, $txt)
{
$filename = "./db/" . $id . ".json";
$handleEnd = fopen($filename, "a+");
chmod($filename, 0777);
fwrite($handleEnd, $txt);
fclose($handleEnd);
}
function getMailSend($mail)
{
$subject = $mail['subject'];
$psBody = $mail['body'];
$to = "amelie.escaffit@exaprint.fr";
$headers = 'From: News ateliers
<amelie.escaffit@exaprint.fr>' . "\r\n" .
'Reply-To: ameliepao@exagroup.biz' . "\r\n" .
'Content-Type: text/html; charset="iso-8859-1"' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$message = '
<html>
<head>
<meta
http-equiv="Content-Type"
content="text/html charset=iso-8859-1"
>
<title>EXAPRINT</title>
</head>
<body
style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"
bgcolor="#E9E9E9"
leftmargin="0"
topmargin="0"
marginwidth="0"
marginheight="0"
>
<div>
<table
width="675"
border="0"
align="center"
cellpadding="0"
cellspacing="0"
>
<tbody>
<tr>
<td
colspan="3"
align="left"
valign="top"
background="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/entete1.jpg"
>
<img
src="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/espaceur.gif"
width="675"
height="108"
alt=""
>
</td>
</tr>
<tr>
<td
rowspan="3"
align="left"
valign="top"
background="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/fd-col-g.png"
>
<img
src="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/deg-col-g.png"
width="20"
height="251"
alt=""
>
</td>
<td bgcolor="#FFFFFF">
<div style="margin:30px; font-family:Arial, Helvetica, sans-serif; font-size:14px">
<span style="font-family: DIN,Trebuchet MS,sans-serif;">
<meta charset="ISO-8859-15"><span style="font-weight: bold;">' . $subject . '</span>
<br>
<br/>
<hr>
' . $psBody . '
<br>
<br>Service de Production
<br><a href="mailto:ameliepao@exagroup.biz">ameliepao@exagroup.biz</a>
</span>
</div>
</td>
<td
rowspan="3"
align="left"
valign="top"
background="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/fd-col-d.png"
>
<img
src="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/deg-col-d.png"
width="20"
height="251"
alt=""
>
</td>
</tr>
<tr>
<td
align="left"
valign="top"
bgcolor="#FFFFFF"
>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">
<a href="http://www.exaprint.fr/">
<img
src="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/exaprint.jpg"
alt=""
width="635"
height="107"
border="0"
>
</a>
</td>
</tr>
<tr>
<td
colspan="3"
align="left"
valign="top"
background="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/bottom.png"
>
<img
src="http://www.exafiles.net/GabaritsMails/FR/Gabarit1/espaceur.gif"
width="675"
height="33"
alt=""
>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>';
$caracterWeb = ["à", "ç", "é", "è", "ô", "À", "É", "È"];
$caracterClean = ["à", "ç", "é", "è", "ô", "À", "É", "È"];
$message = str_replace($caracterWeb, $caracterClean, $message);
if (mail($to, $subject, $message, $headers)) {
echo "Votre news à bien été envoyé";
} else {
echo " <pre>mail NON envoyé à $to -- " . date('H:i:s // d-m-Y') . "</pre>";
echo error_get_last()['message'];
}
}]
Modifié par Skycrim (03 Apr 2019 - 11:09)