1

私は 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')

動作しませんが、コントローラーで自動ロードされた値を取得する方法は? 助けてください

4

2 に答える 2

4

以下の設定ファイルを自動ロードする必要があります。$autoload['config'] = 'email';

于 2012-05-07T10:31:14.850 に答える
3

自動ロードする必要がない場合は、

1) Place the email.php under application/config
2) In your controller

   $this->config->load('email');
   $this->config->item('support_email')
于 2012-05-07T10:39:15.843 に答える