【问题标题】:SMPT timeout error with CodeIgniter 3CodeIgniter 3 的 SMTP 超时错误
【发布时间】:2016-05-10 10:25:39
【问题描述】:

在我的本地环境中,电子邮件可以工作,但是一旦我转移到我的在线网站,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,需要配置什么吗?

【问题讨论】:

  • 您使用的是网站托管服务提供商还是您自己的专用/VPS 服务器?例如,了解您的提供商是谁,看看他们是否阻止了传出端口 465,这可能会有所帮助。

标签: php codeigniter email smtp


【解决方案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);

【讨论】:

  • 我应该将它保存在/config/email.php 中吗?该库已自动加载。
  • @GabrielMFernandes 我没听懂你
  • 这个配置是在config文件夹里面的一个名为email.php的文件里,但是你写的$this-&gt;load-&gt;library('email', $config);这行,这个文件里面有必要吗?不是用来直接从控制器加载库吗?
  • 控制器中不使用。它看起来很完美
  • 无论如何,仍然是错误Message: fsockopen(): unable to connect to ssl://smtp.googlemail.com:465 (Connection timed out) :(
猜你喜欢
  • 2018-12-21
  • 2019-01-25
  • 2012-06-01
  • 2010-12-04
  • 1970-01-01
  • 2012-06-01
  • 2012-11-08
  • 1970-01-01
  • 2013-12-11
相关资源
最近更新 更多