0

i'm trying to send that form via gmail :

<!-- form -->
        <form name="contactForm" id="contactForm" method="post" action="inc/sendEmail.php">
            <fieldset>

              <div class="form-field">
                       <input name="contactName" type="text" id="contactName" placeholder="Nom" value="" minlength="2" required="">
              </div>
              <div class="form-field">
                   <input name="contactEmail" type="email" id="contactEmail" placeholder="Email" value="" required="">
               </div>
              <div class="form-field">
                       <input name="contactSubject" type="text" id="contactSubject" placeholder="Sujet" value="">
               </div>                       
              <div class="form-field">
                    <textarea name="contactMessage" id="contactMessage" placeholder="message" rows="10" cols="50" required=""></textarea>
               </div>                      
             <div class="form-field">
                 <button class="submitform">Submit</button>
                 <div id="submit-loader">
                    <div class="text-loader">Sending...</div>                             
                      <div class="s-loader">
                                <div class="bounce1"></div>
                                <div class="bounce2"></div>
                                <div class="bounce3"></div>
                            </div>
                        </div>
              </div>

            </fieldset>
        </form> <!-- Form End -->

I've checked with the developer tools and everything is send correctly My php file is in the inc folder :

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'src/Exception.php';
require 'src/PHPMailer.php';
require 'src/SMTP.php';

if(isset($_POST["submit"])){
$username = 'myadress@gmail.com';
$password = 'mypass';
$to = $username;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;

$mail->IsHTML(true);
$mail->Username = $username;
$mail->Password = $password;
$mail->SetFrom($_POST["contactName"." "."contactEmail"]);
$mail->Subject = $_POST["contactSubject"];
$mail->Body = $_POST["contactMessage"];
$mail->AddAddress($to);

if(!$mail->Send())
{
    echo "Mailer error : " . $mail->ErrorInfo . "<br>";
}}

Actually i can't see any error but i receive no mail so something is wrong (indentation here isn't correct but it's good in my code) Actually i googled for some solutions but no one has worked for it, what am i missing ?

  • Could you set SMTPDebug to 2 and post the result of sending a mail. It'll reveal alot about the sending process. Also where it gets stuck! – Niels Dec 04 '17 at 14:02
  • I tried to put it to 2 but it still doesn't give any indication, even if i add : `error_reporting(-1); ini_set('display_errors', 'On'); set_error_handler("var_dump");` – Stéphane Metz Dec 04 '17 at 14:35

0 Answers0