【发布时间】:2018-02-15 10:08:53
【问题描述】:
在我的一个项目中 CodeIgniter 版本是 2.1.2
这里的系统库邮件是从sendmail发送的
但我想在不使用 sendemail 的情况下全局设置 smtp,并且不想在每个地方发送电子邮件之前设置配置参数。
为了克服这个问题,我在路径“application\config\email.php”上添加了 email.php 文件
添加以下参数值
$config['useragent'] = 'CodeIgniter';
$config['protocol'] = 'smtp';
//$config['mailpath'] = '/usr/sbin/sendmail';
$config['smtp_host'] = 'smtp.gmail.com';
$config['smtp_user'] = 'youremailaddress@gmail.com';
$config['smtp_pass'] = 'yourpassword';
$config['smtp_port'] = 465;
$config['smtp_timeout'] = 5;
$config['wordwrap'] = TRUE;
$config['wrapchars'] = 76;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';
$config['validate'] = FALSE;
$config['priority'] = 3;
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['bcc_batch_mode'] = FALSE;
$config['bcc_batch_size'] = 200;
但它给了我如下错误 遇到以下 SMTP 错误:
Failed to send AUTH LOGIN command. Error:
from:
The following SMTP error was encountered:
to:
The following SMTP error was encountered:
data:
The following SMTP error was encountered:
The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
谁能帮我解决这个问题或以任何其他方式以全局方式设置 smtp 吗?
我将不胜感激最佳答案。
【问题讨论】:
-
所以有几个问题:1)如果直接应用配置,它是否有效? IE。什么时候构建 Email 类? 2)您是否自动加载配置文件? (即 application/config/autoload.php >> config ??)
-
感谢您的回复 1) 不,当我直接应用配置时它不起作用 2) 是的,我已经在 autoload.php 中加载了 email.php 文件,例如 $autoload['config'] = array("email ");
标签: php codeigniter