警告:修剪()预计参数1是串,阵列中的给定的WP-包括在线路973 /类phpmailer.php(

2019-10-22 02:23发布

我试图使用功能wp_mail从我的wordpress网站发送电子邮件,我得到这个错误:

Warning: trim() expects parameter 1 to be string, array given in /var/www/html/wp-includes/class-phpmailer.php on line 973 0

我真的不明白为什么我得到它。

这是我当前的代码:

// Contact form  Ajax 

add_action('wp_ajax_nopriv_submit_contact_form', 'submit_contact_form'); 

function submit_contact_form(){

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

        $email = $_POST['email'];       
        $email_to = "info@yyy.com";

        $host = "ssl://smtp.gmail.com:465";
        $username = 'myEmail@gmail.uk';
        $password = 'mypassword';

        $email_subject = "You have a new email from $email via yyy.com website";
        $message = $_POST['text']; 

        $headers = array ('From' => $email, 'To' => $email_to,'Subject' => $email_subject);
        /*$smtp = Mail::factory('smtp',
          array ('host' => $host,
            'auth' => true,
            'username' => $username,
            'password' => $password));*/

        //$mail = $smtp->send($email_to, $headers, $message);

        wp_mail( $email_to, $headers, $message );

        /*if (PEAR::isError($mail)) {
          echo($mail->getMessage());
        } else {
          echo("Message successfully sent!\n");
        }*/
    }
}



error_reporting(E_ALL);
ini_set("display_errors", 1);

Answer 1:

我安装了一个叫做“后缀”包,它负责从一个Ubuntu服务器(这是服务器的Linux我用)发送电子邮件,它解决了这个问题!



文章来源: Warning: trim() expects parameter 1 to be string, array given in wp-includes/class-phpmailer.php on line 973
标签: php wordpress