Bonjour,

depuis plus d'une semaine, j'essaye d'envoyer des Mails depuis mon site web, mais sans succès.

J'ai testé différentes techniques, comme la fonction Mail, ou PhpMailer, mais toujours le même problème.

Mon site est hébergé chez Hosteur.
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
 
$address = "monmail@mondomaine.fr";
$e_subject = 'vous venez d\'étre contacter par ' . $first_name . '.';
 
$e_body = "vous venez d\'étre contacter par $first_name. de la $wilaya $first_name pour le Service $select_service, Gamme des prix $select_price, projet.";
$e_content = "\"$comments\"";
$e_reply = "Vous pouvez contacter $first_name via email, $email ou par téléphone $phone";
 
$msg = wordwrap( $e_body . $e_content . $e_reply, 70 );
 
$headers = "From: monmail2@mondomaine.fr";
$headers .= "Reply-To:monmail2@mondomaine.fr";
$headers .= "MIME-Version: 1.0";
$headers .= "Content-type: text/plain; charset=utf-8";
$headers .= "Content-Transfer-Encoding: quoted-printable";
 
if(mail($address, $e_subject, $msg, $headers)) {
 
    // Email has sent successfully, echo a success page.
 
    echo "<fieldset>";
    echo "<div id='success_page'>";
    echo "<h1>Email envoyé avec succès.</h1>";
    echo "<p>Merci <strong>$first_name</strong>, Votre Messsage a été envoyé avec succès.Toute l'équipe CyberEye vous remercie.</p>";
    echo "<p>Pour toute question urgente vous pouvez nous joindre par :</p>";
    echo "<p><strong>commercial@cybereye.fr</strong>, <strong>+213</strong></p>";
    echo "</div>";
    echo "</fieldset>";
 
} else {
 
 
    echo '<fieldset><h1 style="background-color:red;">Email non envoyé ERRORERRORERRORERRORERROR.</h1></fieldset>';
 
}
avec PhpMailer
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
 
date_default_timezone_set('Etc/UTC');
require 'PHPMailer/PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2;
//Ask for HTML-friendly debug output
$mail->Debugoutput = 'html';
//Set the hostname of the mail server
$mail->Host = 'smtp.gmail.com';
// use
// $mail->Host = gethostbyname('smtp.gmail.com');
// if your network does not support SMTP over IPv6
//Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission
$mail->Port = 587;
//Set the encryption system to use - ssl (deprecated) or tls
$mail->SMTPSecure = 'tls';
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication - use full email address for gmail
$mail->Username = "mongmail@gmail.com";
//Password to use for SMTP authentication
$mail->Password = "mdp";
//Set who the message is to be sent from
$mail->setFrom('mongmail@gmail.com', 'First Last');
//Set an alternative reply-to address
$mail->addReplyTo('mongmail2@gmail.com', 'First Last');
//Set who the message is to be sent to
$mail->addAddress('mongmail2@gmail.com', 'client');
//Set the subject line
$mail->Subject = 'PHPMailer GMail SMTP test';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'Ceci est un message texte';
//Attach an image file
$mail->addAttachment('phpmailer/phpmailer_mini.png');
//send the message, check for errors
if (!$mail->send()) {
    echo '<div class="error_message" style="background-color:red;color:white;font-size:100%;border-radius:10px;
         border:solid 2px red; margin-bottom:8px; padding:7px;font-weight:bolder;">Mailer Error:</div>'.$mail->ErrorInfo;
 
}else {
echo '<div class="error_message" style="background-color:green;color:white;font-size:100%;border-radius:10px;
     border:solid 2px red; margin-bottom:8px; padding:7px;font-weight:bolder;">Message sent!</div>';
}
Merci d'avance pour votre aide.