我正试图找到一种方法从CodeIgniter发送一封简单的确认电子邮件,但它不起作用,我已经找了好几天,但没有找到任何有用的答案。
我的email.php
文件是:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* Configuration file for Email library
*/
$config['protocol'] = 'smtp';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['smtp_timeout'] = 5;
$config['smtp_host'] = 'smtp.mandrillapp.com';
$config['smtp_port'] = 587;
$config['smtp_user'] = $ENV['*****'];
$config['smtp_pass'] = $ENV['*****'];
?>
我得到的错误是:
Undefined index: [My Mandrill Username] (in the config/email.php file)
Undefined index: [My Mandrill API KEY] (in the config/email.php file)
答案 0 :(得分:0)
此代码与问题无关,因为配置文件应从email
库加载。 ($this->load->config(<config file for mandrill>
)应该定义类似
<?php
$config['mandrill_api_key'] = your_key
?>
答案 1 :(得分:0)
$_ENV
并用一串用户名替换它
和email.php
文件中的API密钥。更改此:
$config['smtp_user'] = $_ENV['*****'];
$config['smtp_pass'] = $_ENV['*****'];
要强>:
$config['smtp_user'] = '*****';
$config['smtp_pass'] = '*****';
加载电子邮件配置文件:
$this->load->config('email');