Welcome Guest, Not a member yet? Register   Sign In
Using email address from config to send email
#1

[eluser]doubleplusgood[/eluser]
Greetings,

I am storing site email addresses in the config, so that it would be easy to change sitewide email addresses if the need arose. In my config I have the following;

Code:
/*
|--------------------------------------------------------------------------
| Site Email Addresses
|--------------------------------------------------------------------------
|
*/
$config['site_email']    = "[email protected]";
$config['sales_email']    = "[email protected]";

However, i'm trying to access this in my controller to send an email as follows;
Code:
$this->_obj->email->from($this->config->item('sales_email'), $this->config->item('site_title'));

This is throwing an error with the controller. Could someone tell me if a config item can be used in this way? And also if you have a solution, that would be grand. Big Grin

Neil
#2

[eluser]$ilovephp[/eluser]
why not try the set_item() function?

Code:
$this->config->set_item('site_email','[email protected]');
$this->config->set_item('sales_email','[email protected]');

but i doubt it will give same problem. Why not post the error message instead?
#3

[eluser]mddd[/eluser]
Another easy way is to put some constants in /config/constants.php.
I like constants because using them is shorter to write.

Like so:
Code:
define('SITE_EMAIL', '[email protected]');
define('SALES_EMAIL', '[email protected]');

In your code you can use these constants like
Code:
$this->email->from( SITE_EMAIL );




Theme © iAndrew 2016 - Forum software by © MyBB