duandan9680 2015-02-27 09:54
浏览 291
已采纳

警告:trim()期望参数1为字符串,在第973行的wp-includes / class-phpmailer.php中给出数组

I am trying to send an email from my wordpress website using the function wp_mail and I am getting this error:

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

I don't really understand why I am getting it.

This is my current code:

// 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!
");
        }*/
    }
}



error_reporting(E_ALL);
ini_set("display_errors", 1);
  • 写回答

1条回答 默认 最新

  • dqd54099 2015-03-01 09:20
    关注

    I installed a package called "PostFix" which is responsible for sending emails from an Ubuntu server (which is the servers linux I use), and it solved the problem!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度