PHP联系我们不工作

时间:2017-08-28 16:51:03

标签: php email

我们买了这个名为" Classiera"但联系我们的功能只是不起作用...我们设置了SMTP插件,它在测试时有效

我们使用loco translate快速翻译其中一些,但我不能怀疑它干扰网站代码,只有用户代理看到的,对吧? 这段代码有问题吗?

如果需要,请提供完整的模板网站代码< 3

if(isset($_POST['submitted'])) {

    //Check to make sure that the name field is not empty
    if(trim($_POST['contactName']) === '') {
        $nameError = $classieraContactNameError;
        $hasError = true;

    } elseif(trim($_POST['contactName']) === 'Name*') {
        $nameError = $classieraContactNameError;
        $hasError = true;

    }   else {
        $name = trim($_POST['contactName']);

    }
    //Check to make sure that the subject field is not empty
    if(trim($_POST['subject']) === '') {
        $subjectError = $classiera_contact_subject_error;
        $hasError = true;
    } elseif(trim($_POST['subject']) === 'Subject*') {
        $subjectError = $classiera_contact_subject_error;
        $hasError = true;
    }   else {
        $subject = trim($_POST['subject']);
    }

    //Check to make sure sure that a valid email address is submitted
    if(trim($_POST['email']) === '')  {
        $emailError = $classieraContactEmailError;
        $hasError = true;
    } else if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$/i", trim($_POST['email']))) {
        $emailError = $classieraContactEmailError;
        $hasError = true;
    } else {
        $email = trim($_POST['email']);
    }

    //Check to make sure comments were entered  
    if(trim($_POST['comments']) === '') {
        $commentError = $classieraConMsgError;
        $hasError = true;
    } else {
        if(function_exists('stripslashes')) {
            $comments = stripslashes(trim($_POST['comments']));
        } else {
            $comments = trim($_POST['comments']);
        }
    }

    //Check to make sure that the human test field is not empty
    $classieraCheckAnswer = $_POST['humanAnswer'];
    if(trim($_POST['humanTest']) != $classieraCheckAnswer) {
        $humanTestError = esc_html__('Not Human', 'classiera');
        $hasError = true;
    } else {

    }

    //If there is no error, send the email
    if(!isset($hasError)) {
$emailTo = $contact_email;
        $subject = $subject;    
        $body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
        $headers = 'From website <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;

        wp_mail($emailTo, $subject, $body, $headers);

        $emailSent = true;


}

}

0 个答案:

没有答案