php联系表单只有'消息'没有通过

时间:2017-07-06 13:03:00

标签: php phpmailer

您好我已经设置了联系表单,最初它没有发送我设法修复的文件上传,但现在它没有从表单发送'消息'。姓名/电子邮件通过确认。请帮忙,我确定这是错误的文件?

{
  "rules": {
    // default rules are false if not specified

    "posts": {
      ".read": true, // everyone can read all posts

      "$postId": {
        // a new post can be created if it does not exist
        // existing posts can only be edited by their original "author"
        ".write": "!data.exists() && newData.exists() || data.child('author').val() == auth.uid",
        ".validate": "newData.hasChildren(['title', 'author', 'timestamp'])",
      }
    }
  }
}

这是联系表格中的相关部分

<?PHP
require_once("class.phpmailer.php");
/*
Interface to Captcha handler
*/
class FG_CaptchaHandler
{
    function Validate() { return false;}
    function GetError(){ return '';}
}
class FGContactForm
{
    var $receipients;
    var $errors;
    var $error_message;
    var $name;
    var $email;
    var $message;
    var $from_address;
    var $form_random_key;
    var $conditional_field;
    var $arr_conditional_receipients;
    var $fileupload_fields;
    var $captcha_handler;
    var $mailer;
    function FGContactForm()
    {
        $this->receipients = array();
        $this->errors = array();
        $this->form_random_key = 'HTgsjhartag';
        $this->conditional_field='';
        $this->arr_conditional_receipients=array();
        $this->fileupload_fields=array();
        $this->mailer = new PHPMailer();
        $this->mailer->CharSet = 'utf-8';
    }
    function EnableCaptcha($captcha_handler)
    {
        $this->captcha_handler = $captcha_handler;
        session_start();
    }
    function AddRecipient($email,$name="")
    {
        $this->mailer->AddAddress($email,$name);
    }
    function SetFromAddress($from)
    {
        $this->from_address = $from;
    }
    function SetFormRandomKey($key)
    {
        $this->form_random_key = $key;
    }
    function GetSpamTrapInputName()
    {
        return 'sp'.md5('KHGdnbvsgst'.$this->GetKey());
    }
    function SafeDisplay($value_name)
    {
        if(empty($_POST[$value_name]))
        {
            return'';
        }
        return htmlentities($_POST[$value_name]);
    }
    function GetFormIDInputName()
    {
        $rand = md5('TygshRt'.$this->GetKey());
        $rand = substr($rand,0,20);
        return 'id'.$rand;
    }

    function GetFormIDInputValue()
    {
        return md5('jhgahTsajhg'.$this->GetKey());
    }
    function SetConditionalField($field)
    {
        $this->conditional_field = $field;
    }
    function AddConditionalReceipent($value,$email)
    {
        $this->arr_conditional_receipients[$value] =  $email;
    }
    function AddFileUploadField($file_field_name,$accepted_types,$max_size)
    {
            $this->fileupload_fields[] =
            array("name"=>$file_field_name,
            "file_types"=>$accepted_types,
            "maxsize"=>$max_size);
    }
    function ProcessForm()
    {
        if(!isset($_POST['submitted']))
        {
           return false;
        }
        if(!$this->Validate())
        {
            $this->error_message = implode('<br/>',$this->errors);
            return false;
        }
        $this->CollectData();
        $ret = $this->SendFormSubmission();
        return $ret;
    }
    function RedirectToURL($url)
    {
        header("Location: $url");
        exit;
    }
    function GetErrorMessage()
    {
        return $this->error_message;
    }
    function GetSelfScript()
    {
        return htmlentities($_SERVER['PHP_SELF']);
    }
    function GetName()
    {
        return $this->name;
    }
    function GetEmail()
    {
        return $this->email;
    }
    function GetMessage()
    {
        return htmlentities($this->message,ENT_QUOTES,"UTF-8");
    }
/*--------  Private (Internal) Functions -------- */
    function SendFormSubmission()
    {
        $this->CollectConditionalReceipients();
        $this->mailer->CharSet = 'utf-8';

        $this->mailer->Subject = "Contact form submission from $this->name";
        $this->mailer->From = $this->GetFromAddress();
        $this->mailer->FromName = $this->name;
        $this->mailer->AddReplyTo($this->email);
        $message = $this->ComposeFormtoEmail();
        $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message)));
        $this->mailer->AltBody = @html_entity_decode($textMsg,ENT_QUOTES,"UTF-8");
        $this->mailer->MsgHTML($message);
        $this->AttachFiles();
        if(!$this->mailer->Send())
        {
            $this->add_error("Failed sending email!");
            return false;

          }
        return true;
    }
    function CollectConditionalReceipients()
    {
        if(count($this->arr_conditional_receipients)>0 &&
          !empty($this->conditional_field) &&
          !empty($_POST[$this->conditional_field]))
        {
            foreach($this->arr_conditional_receipients as $condn => $rec)
            {
                if(strcasecmp($condn,$_POST[$this->conditional_field])==0 &&
                !empty($rec))
                {
                    $this->AddRecipient($rec);
                }
            }
        }
    }

所以一切都会回来,除了'消息'的帮助将非常感谢

提前致谢

0 个答案:

没有答案
相关问题