首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CodeIgniter/TankAuth forgot_password函数发送没有内容的电子邮件

CodeIgniter/TankAuth forgot_password函数发送没有内容的电子邮件
EN

Stack Overflow用户
提问于 2014-04-14 10:04:31
回答 1查看 112关注 0票数 0

最近,一款现有的CodeIgniter产品转移到了它自己的VPS上,一切都在顺利进行。但是,由于某些原因,密码已经失效,当运行forgot_password函数时,电子邮件以完整的主题行到达,然而,电子邮件没有任何内容。完全没有。这是违规代码:

代码语言:javascript
复制
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库发送电子邮件:

代码语言:javascript
复制
<?php

如果(!定义(‘BASEPATH’))退出(‘不允许直接脚本访问’);

代码语言:javascript
复制
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();
    }
}
?>

该电子邮件完全正常,并产生以下输出:

代码语言:javascript
复制
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。

任何想法,检查什么或任何资源,你可以想到,将非常感谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-14 10:59:55

此服务器的PHP.INI文件需要行:

代码语言:javascript
复制
sendmail_path = /usr/sbin/sendmail -t -i

立刻解决了问题。不完全确定为什么电子邮件的部分会出现,而不是身体,但它是有效的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23057292

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档