最近,一款现有的CodeIgniter产品转移到了它自己的VPS上,一切都在顺利进行。但是,由于某些原因,密码已经失效,当运行forgot_password函数时,电子邮件以完整的主题行到达,然而,电子邮件没有任何内容。完全没有。这是违规代码:
function _send_email($type, $email, &$data) {
$this->load->library('email');
$this->email->from($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
$this->email->reply_to($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
$this->email->to($email);
$this->email->subject(sprintf($this->lang->line('auth_subject_' . $type), $this->config->item('website_name', 'tank_auth')));
$this->email->message($this->load->view('email/' . $type . '-html', $data, TRUE));
echo $this->load->view('email/' . $type . '-html', $data, TRUE);
$this->email->set_alt_message($this->load->view('email/' . $type . '-txt', $data, TRUE));
$this->email->send();
}我编写了一个简短的PHP脚本来使用相同的CodeIgniter库发送电子邮件:
<?php如果(!定义(‘BASEPATH’))退出(‘不允许直接脚本访问’);
class EmailTest extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->library('tank_auth');
$this->lang->load('tank_auth');
}
function sendTest(){
$this->load->library('email');
$this->email->from($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
//$this->email->reply_to($this->config->item('webmaster_email', 'tank_auth'), $this->config->item('website_name', 'tank_auth'));
$this->email->to('cameron.j.leafe@gmail.com');
$this->email->subject("Here and There");
$this->email->message("I hear you are an example");
$this->email->send();
echo $this->email->print_debugger();
}
}
?>该电子邮件完全正常,并产生以下输出:
User-Agent: CodeIgniter
Date: Mon, 14 Apr 2014 18:55:55 +1000
From: "EPI Dashboard" <epi@epidashboard.com>
Return-Path: <epi@epidashboard.com>
Reply-To: "epi@epidashboard.com" <epi@epidashboard.com>
X-Sender: epi@epidashboard.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <534ba29b87010@epidashboard.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_534ba29b8708b"
=?utf-8?Q?Here_and_There?=
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_534ba29b8708b
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
I hear you are an example
--B_ALT_534ba29b8708b
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
I hear you are an example
--B_ALT_534ba29b8708b--服务器是运行后缀的CentOS 6 VPS,显然是PHP/MySql/Apache。
任何想法,检查什么或任何资源,你可以想到,将非常感谢。
发布于 2014-04-14 10:59:55
此服务器的PHP.INI文件需要行:
sendmail_path = /usr/sbin/sendmail -t -i立刻解决了问题。不完全确定为什么电子邮件的部分会出现,而不是身体,但它是有效的。
https://stackoverflow.com/questions/23057292
复制相似问题