CodeIgniter Forums
CI 2.0 Extended Email class stopped working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CI 2.0 Extended Email class stopped working (/showthread.php?tid=33725)



CI 2.0 Extended Email class stopped working - El Forum - 09-06-2010

[eluser]Ki[/eluser]
I have migrated from older version to 2.0 And while there were little issues, one of them is the extended MY_Email that now refuses to work. It worked in the older version.
I have extended the CI email library as such (in my core folder):

Code:
class MY_Email extends CI_Email {

    function  __construct() {
    $this->CI = & get_instance();

        parent::CI_Email($this->CI->config->config['email']);
    }

function email_something(){
   // data processing + emailing is done here
}
}

In my controller I have:
Code:
$result=$this->email->email_something($_POST);

I am perplexed why it stopped working in CI 2.0

Code:
Fatal error: Call to undefined method CI_Email::email_something() in



CI 2.0 Extended Email class stopped working - El Forum - 09-08-2010

[eluser]InsiteFX[/eluser]
Did you place the library in application/core ?

InsiteFX


CI 2.0 Extended Email class stopped working - El Forum - 09-09-2010

[eluser]Ki[/eluser]
Thank you,
Email is not a core library, therefore should not have been placed in /core/ I moved it to Applications directory and now its all good :-)


CI 2.0 Extended Email class stopped working - El Forum - 02-23-2011

[eluser]diZzyCoDeR[/eluser]
Like Zombigeddon, this thread rises from the dead and walks amongst the living once more.

I did same thing as OP and having same trouble, but, I had moved MY_Email to /application/libraries/ already.

So confuzded. Any thoughts on why it won't auto-extend when called normally (actually I'm autoloading 'email')?

But I'm not extending it with the instance like OP... is that wrong? This is based on the CI manual under extending libraries.

Code:
class MY_Email extends CI_Email {

        var    $_attach_cont    = array();

        function __construct() {
            parent::__construct();
        }

        /**
         * Assign file attachments
         *
         * @access    public
         * @param    string
         * @return    void
         */
        function attach($filename, $disposition = 'attachment', $content = '')
        {
                $this->_attach_name[] = $filename;
                $this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename))));
                $this->_attach_disp[] = $disposition; // Can also be 'inline'  Not sure if it matters
                $this->_attach_cont[] = $content;
                return $this;
        }