我正在使用CodeIgniter,我想自动加载电子邮件配置文件并在我的控制器库中使用。
我将电子邮件配置添加到 config / autoload.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
...some code ...
*/
$autoload['libraries'] = array(
'database',
'session',
'locale',
'util/ScriptLoader',
'activity/Message',
'Auth_lib',
'email'
);
我的 config / email.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
...some code ...
*/
$config['useragent'] = "CodeIgniter";
$config['mailpath'] = "/usr/bin/sendmail"; // or "/usr/sbin/sendmail"
$config['protocol'] = "mail";
$config['smtp_host'] = "localhost";
$config['smtp_user'] = "";
$config['smtp_pass'] = "";
$config['smtp_port'] = "25";
$config['system_email'] = "noreply@xxxx.com";
$config['help_email'] = "help@xxxxx.com";
$config['inquiries_email'] = "inquiries@xxxx.com";
$config['support_email'] = "support@xxxx.com";
我尝试使用
在我的控制器中获取support_email
值
$this->config->item('support_email')
但不工作,如何在控制器中获取自动加载的值?请帮忙
答案 0 :(得分:4)
您需要在$autoload['config'] = 'email';
答案 1 :(得分:3)
如果您不需要自动加载,
1) Place the email.php under application/config
2) In your controller
$this->config->load('email');
$this->config->item('support_email')