Welcome Guest, Not a member yet? Register   Sign In
DRY sendEmail() ?
#1

(This post was last modified: 11-25-2015, 08:05 PM by solidcodes.)

I just created a simple DRY sendEmail() method.
Hoping this will save me time from not re-inventing the wheel over and over again.

here is the codes
Code:
/***
     *  author: warren nazareno
     *  email: [email protected]
     *  purpose: Will send email message (DRY)
     *  Date created: November 26, 2015
     ***/      
    public function sendEmail($data = array())
    {
        $this->load->library('email');
        
        $this->email
            ->from($data['from_email'], $data['from_name'])
            ->to($data['to'])
            ->cc($data['cc'])
            ->subject($data['subject'])
            ->message($data['message'])
            ->set_mailtype($data['mailtype']);        

        $this->email->send();
}

Below is an example of how to call the method above from controller
Code:
public function callSendEmail()
{
        $email_data = array(
                    'from_email'    => '[email protected]',
                    'from_name'     => 'George',
                    'to'            => '[email protected]',
                    'cc'            => '[email protected]',
                    'bcc'           => '',
                    'subject'       => 'Lawyers',
                    'message'       => 'I hate lawyers',
                    'mailtype'      => 'HTML'
                );
        
        $this->sendEmail($email_data);      

}

It's just a simple first step.
currently I put it under MY_Controller.

Should I put this under helper file? or stick with MY_Controller.

thanks in advance.
Reply


Messages In This Thread
DRY sendEmail() ? - by solidcodes - 11-25-2015, 08:00 PM
RE: DRY sendEmail() ? - by Bhavesh - 11-25-2015, 09:58 PM
RE: DRY sendEmail() ? - by solidcodes - 11-25-2015, 10:22 PM
RE: DRY sendEmail() ? - by InsiteFX - 11-26-2015, 07:04 AM
RE: DRY sendEmail() ? - by solidcodes - 11-26-2015, 04:51 PM
RE: DRY sendEmail() ? - by solidcodes - 11-26-2015, 05:00 PM
RE: DRY sendEmail() ? - by orionstar - 11-26-2015, 06:02 PM
RE: DRY sendEmail() ? - by solidcodes - 11-26-2015, 06:27 PM
RE: DRY sendEmail() ? - by solidcodes - 11-26-2015, 06:30 PM
RE: DRY sendEmail() ? - by kenjis - 11-26-2015, 09:04 PM
RE: DRY sendEmail() ? - by solidcodes - 11-27-2015, 12:50 AM
RE: DRY sendEmail() ? - by InsiteFX - 11-27-2015, 05:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB