[Solved] Codeigniter: Load Library in a Core Class |
I would say that in the most cases it won't make sense and it is more advisable to only send an email in case of some particular processes.
In this specific project I want to receive an email in case of an error (no information or debug message) on the production environment. The reason for that is that I do not want to monitor the project all the time. Thus, I adjusted the above posted code slightly: PHP Code: class MY_Log extends CI_Log { Thank you for your input
I did find one way to incorporate the CI email class. It uses the same basic approach you have used in loading PHPMailer. This even loads and uses application/config/email.php . (It is assumed to be there which is dangerous but this is just a proof-of-concept.)
Code: class MY_Log extends CI_Log For this to work there is one small hack that MUST BE MADE to system/libraries/Email.php The last line in the constructor must be removed (or commented out) Code: //log_message('info', 'Email Class Initialized'); Otherwise a loop condition exists where that call (log_message) tries to load the Log class, which tries to instantiate the Email class and... around and around we go. So, there's your CI email class. Hope you don't want to load any other core libraries. |
Welcome Guest, Not a member yet? Register Sign In |