Welcome Guest, Not a member yet? Register   Sign In
Email Library Constructor
#1

Having trouble with this, maybe someone can help.

I have a Library that handles on my email functions.  I have 3 environments setup.  Development, Test & Production.  What I am trying to do is have different application names and mailto addresses depending on the environment.  I've tried to do this through constructor but no luck.  Basically, I don't want test emails going to real users and I'd like to better distinguish what is test from what is actual data for my testers who are also users...

PHP Code:
public function __construct()
 
   {
 
       parent::__construct();
 
$this->load->library('email');

if(
ENVIRONMENT == 'development')
 {
 
$emailto 'developer@email';
 
$appname '***DEVELOPMENT APP***';
 }
 elseif(
ENVIRONMENT == 'testing')
 {
 
$emailto 'test@email';
 
                       $appname '*TEST APP*';
 }
 elseif(
ENVIRONMENT == 'production')
 {
 
$emailto 'dynamic@email';
 
                       $appname 'LIVE APP';
 }
 
   }

public function 
email()
 {
 
$message 'Email Message.';

 
$this->email->from($XXX'XXX');
 
$this->email->to($emailto);
 
$this->email->subject($appname.' -> Email Subject');
 
$this->email->message($message);
 
$this->email->send();
 } 

I can get this to work if I put the code directly in each function but it would be so much nicer if it could just all be in one spot!!

Sorry for any formatting problems, I am not a forum pro...  THANK YOU.
Reply


Messages In This Thread
Email Library Constructor - by 330Root - 06-01-2015, 02:06 PM
RE: Email Library Constructor - by Avenirer - 06-02-2015, 01:38 AM
RE: Email Library Constructor - by JayAdra - 06-02-2015, 03:20 AM
RE: Email Library Constructor - by 330Root - 06-02-2015, 06:58 AM
RE: Email Library Constructor - by Avenirer - 06-02-2015, 07:08 AM
RE: Email Library Constructor - by 330Root - 06-02-2015, 07:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB