CodeIgniter tankauth不使用GMail

时间:2012-10-25 21:44:22

标签: php codeigniter smtp tankauth

我在本地开发环境中设置了WAMP服务器(启用了php_openssl扩展)。我安装了Code Igniter并尝试配置TankAuth,我想使用GMail(实际上是Google Apps)来发送测试邮件。

我浏览了以下配置网址

根据上面的输入,我更新了tank auth的_send_email功能,如下所示

function _send_email($type, $email, &$data)
{
    $this->load->library('email');

    $config['protocol'] = "smtp";
    $config['smtp_host'] = "ssl://smtp.googlemail.com";
    $config['smtp_port'] = "465";
    $config['smtp_user'] = "mymail@youthpark.org";//also valid for Google Apps Accounts
    $config['smtp_pass'] = "mypass";
    $config['charset'] = "utf-8";
    $config['mailtype'] = "html";
    $config['newline'] = "\r\n";

    $this->email->initialize($config); 

    $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));
    $this->email->set_alt_message($this->load->view('email/'.$type.'-txt', $data, TRUE));
    //$this->email->send();

    if ( ! $this->email->send())
    {
        show_error($this->email->print_debugger());
    } else {
        //echo('DONE');        
    } 
}

我收到消息mail sent..但实际上没有发送邮件。有人可以指出我在做错的地方吗?

在GMail设置中也启用了弹出窗口

3 个答案:

答案 0 :(得分:1)

不要在Tank Auth中编辑_send_email功能。而是添加

$config['protocol'] = "smtp";
$config['smtp_host'] = "ssl://smtp.googlemail.com";
$config['smtp_port'] = "465";
$config['smtp_user'] = "mymail@youthpark.org";//also valid for Google Apps Accounts
$config['smtp_pass'] = "mypass";

到“config”文件夹中的“email.php”文件。

这对我有用

答案 1 :(得分:0)

您是否检查过日志以查看是否存在错误?

我使用邮戳处理所有邮件传递,他们有一些免费发送,并且还有CI的火花。

我在我的设置启动中用于新项目。检查一下:

https://github.com/ramirors/DD-Auth

答案 2 :(得分:0)

我遇到了同样的问题。以下_send_email功能以及删除/application/config/email.php对我有用:

function _send_email($type, $email, &$data)
{       
    $config['protocol'] = 'smtp'; 
    $config['smtp_host'] = 'ssl://smtp.googlemail.com'; 
    $config['smtp_port'] = 465; 
    $config['smtp_user'] = 'my.email.address@gmail.com'; 
    $config['smtp_pass'] = 'NiceTry'; 
    $config['mailtype'] = 'html';

    $this->load->library('email', $config); 

    $this->email->set_newline("\r\n"); 

    $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));
    $this->email->set_alt_message($this->load->view('email/'.$type.'-txt', $data, TRUE));

    if ($this->email->send()) { 
        echo "Sent!"; 
    } else { 
        echo "FAILED"; 
    } 

}

Tank Auth Email Problem让我开始走正确的道路。