邮件正文为空

时间:2018-12-12 16:09:41

标签: php

这是我的表格。但是邮件发送选项无法正常工作。我收到错误消息“邮件错误:邮件正文为空”。有人可以帮我解决这个问题吗?

HTML表单

               

             <input type="text" name="nom" required id="contact__name" placeholder="Nom complet *"><span id="prenom-yok"></span><br><br>
          </div>
          <div>
             <input type="email" name="mail" id="contact__mail" placeholder="votre-email@gmail.com *" required><span id="mail-yok"></span><br><br>
          </div>
          <div>
             <textarea type="text" name="msg" class="msg-input" id="contact__msg" placeholder="Message"></textarea><br><br>
          </div>
          <p>*<span> champs obligatoires.</span></p>
          <div>
              <button class="btn-submit"  id="submit-msg" type="submit" 

name =“ submit”>特使               

      </form>

代码PHP

<?php
       error_reporting(E_STRICT);
       require_once('class.phpmailer.php'); 
         $mail  = new PHPMailer();
         $mail->Host = "smtp.gmail.com";  

         $mail->IsSMTP();
         $mail->SMTPDebug =1;
         $mail->SMTPAuth = true;
         $mail->SMTPKeepAlive = true;
         $mail->Username   = "contactform@gmail.com";
         $mail->Password   = "cf12345698";

         $mail->Port = 465;
         $mail->SMTPSecure = "ssl";
         $mail->Subject = 'PHPMailer GMail SMTP test';
         $address = "contactform@gmail.com";
         $mail->SetFrom($address, 'First Last');
         $email = trim($_POST["mail"]);
         $mail->AddAddress($email, "John Doe");

         $msg = trim($_POST["msg"]);
         $mail->body = $msg;

           $mail->Send(); 
            if($mail->Send()) {
              echo "Message sent!";
              echo $msg;
            } else {
              echo "Mailer Error: " . $mail->ErrorInfo;
              echo  "Not ok " . $msg;
            }
     ?>

0 个答案:

没有答案