最近将现有的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
如果(定义(&#39;!基本路径&#39;)) 退出(&#39;不允许直接访问脚本&#39;);
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。
对于您要检查的内容或您能想到的任何资源的任何想法都将非常感激。
答案 0 :(得分:0)
此服务器的PHP.INI文件需要包含以下行:
sendmail_path = /usr/sbin/sendmail -t -i
立即修复了问题。不完全确定为什么电子邮件的某些部分出现而不是正文,但它确实有效。