使用phpmailer发送邮件但无法获取表单内容

时间:2014-09-26 09:50:16

标签: php forms email post phpmailer

我收到电子邮件,但我没有从表单中获取内容,虽然我已从表单中删除了enctype标记以下是输出我收到的电子邮件正文

名称: 组织: 邮寄地址: 市: 国家: 电子邮件:
电话:
评论:

我做了什么错事,任何人都可以提供帮助。

   <?php
     require("/home/public_html/phpMailerTesting/PHPMailer_5.2.0/class.phpmailer.php");
     $mail = new PHPMailer();

     $mail->IsSMTP();                                      // set mailer to use SMTP


     $mail->Host = "localhost";  // specify main and backup server

     $mail->SMTPAuth = true;     // turn on SMTP authentication

     $mail->Username = "sendfromphpmailer@xxx.com";  // SMTP username

     $mail->Password = "12345"; // SMTP password
    enter code here


     $name=$_POST['name'];

     $email=$_POST['mail'];

     $message=$_POST['comment1'];

     $mail->From ="sendfromphpmailer@xxx.com" ;

     $mail->FromName = $_POST["name"];

     $mail->AddAddress("receivefromphpmailer@xxx.com");
                  // name is optional
     $mail->WordWrap = 50;                                 // set word wrap to 50 characters

     $mail->IsHTML(true);                                  // set email format to HTML

     $mail->Subject = "You have received feedback from your website!";

     $mail->Body    = "Name:$name

     Organisation: $organisation

     Postal Address: $PostalAddress

     City: $City

     Country: $Country

     Email:  $email

     Telephone:  $telephone

     Comments:  $comments";
    //$mail->AltBody = "This is the body in plain text for non-HTML mail clients";

    if(!$mail->Send())
    {
     echo "Message could not be sent. <p>";
     echo "Mailer Error: " . $mail->ErrorInfo;
     exit;
   }
    echo "Message has been sent";
?>

0 个答案:

没有答案