CodeIgniter 3的SMPT超时错误

时间:2016-02-01 20:16:25

标签: php codeigniter email smtp

在我的本地环境中,电子邮件可以正常运行,但是一旦我转移到我的在线网站,smtp电子邮件就无法运行并显示超时错误。

这是我的config/email.php文件:

<?php defined('BASEPATH') OR exit('No direct script access allowed.');

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = '[email]';
$config['smtp_pass'] = '[password]';
$config['smtp_timeout'] = 30;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;

我使用Cpanel,我需要配置一些东西吗?

1 个答案:

答案 0 :(得分:1)

smtp_host应该更改

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = $sender_email;
$config['smtp_pass'] = $sender_password;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$this->load->library('email', $config);