[eluser]Watermark Studios[/eluser]
Okay, so I am running through the video tutorials in the Wiki and I am finishing up the email tutorial.
This is the error I'm getting right now:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined variable: config
Filename: controllers/email.php
Line Number: 12
I moved my configuration information to a file called email.php in the config folder. That file looks like:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config['protocol'] = 'sendmail';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = '**********';
$config['smtp_pass'] = '**********';
Keep in mind that I have to use the sendmail protocol because HostMonster doesn't support the smtp protocol. When I had the $config array defined in my email.php controller, everything worked fine. Now that I have the $config array defined in a config folder file it still works, but I get the error at the top of the page.
Below is my code from my email.php in the controller folder:
Code:
<?php
class Email extends Controller
{
function __construct()
{
parent::Controller();
}
function index()
{
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('********@gmail.com', 'Ken Anderson');
$this->email->to('********@gmail.com');
$this->email->subject('This is an e-mail test');
$this->email->message('Its working');
$path = $this->config->item('server_root');
$file = $path . '/codeigniter/attachments/yourinfo.txt';
$this->email->attach($file);
if($this->email->send())
{
echo 'Your email was sent, fool';
}
else
{
show_error($this->email->print_debugger());
}
}
}
Attached is a JPG of my filesystem setup.
I understand that technically $config is not defined in the controller, but it is through the email.php file in the config folder.
Please help
Ken