Home Articles

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

Asked
Viewed 1794 times
0

最近将现有的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

if(!defined('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 .

任何关于检查内容或任何您能想到的资源的想法都将不胜感激 .

1 Answer

  • 0

    此服务器的PHP.INI文件需要具有以下行:

    sendmail_path = /usr/sbin/sendmail -t -i
    

    这立即解决了问题 . 不完全确定为什么电子邮件的部分显示而不是身体,但它的工作原理 .

Related