警告:trim() 期望参数 1 是字符串,在 wp-includes/class-phpmailer.php 中给出的数组 973 [英] Warning: trim() expects parameter 1 to be string, array given in wp-includes/class-phpmailer.php on line 973
本文介绍了警告:trim() 期望参数 1 是字符串,在 wp-includes/class-phpmailer.php 中给出的数组 973的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 wp_mail 函数从我的 wordpress 网站发送电子邮件,但出现此错误:
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.
这是我当前的代码:
// 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);
推荐答案
我安装了一个名为PostFix"的包,它负责从 Ubuntu 服务器(这是我使用的服务器 linux)发送电子邮件,它解决了问题!
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!
这篇关于警告:trim() 期望参数 1 是字符串,在 wp-includes/class-phpmailer.php 中给出的数组 973的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文