![]() |
Having trouble getting Email library to load - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Having trouble getting Email library to load (/showthread.php?tid=36158) |
Having trouble getting Email library to load - El Forum - 11-23-2010 [eluser]ihateregisteringforastupidforum[/eluser] Using CI 1.7.2. So I'm trying to make OpenVBX use CI's Email library, rather than php's own mail(), because on some hosts you cannot use that. No mail() function, just SMTP access. I don't get why, but every time I try to add $this->load->library('email'); inside the function that is supposed to handle sending emails, I get a blank page. PHP just refuses to parse past that point. What am I missing? Original Code: Code: function openvbx_mail($recipient, $subject, $template, $maildata = array()) So I can see that mail() can be replaced with $this->email->send();, or better off, to keep OpenVBX happy, I can do a if(!$this->email->send() ![]() Modified code: Code: function openvbx_mail($recipient, $subject, $template, $maildata = array()) Problem is, like I said, if I try to get the Email library loaded, I get a white page, php stops parsing. I don't know why but I can't even get PHP to output all messages (and errors). I have the proper php.ini params set... beats me! Any ideas would be appreciated - including helping me get to see the error messages at least. But trying to fix it blindly gets frustrating quick. EDIT: I found config.php and noticed that I can turn debugging on there. It was overriding my php.ini. Having trouble getting Email library to load - El Forum - 11-23-2010 [eluser]dudeami0[/eluser] Code: $this->load->library('email'); Having trouble getting Email library to load - El Forum - 11-23-2010 [eluser]ihateregisteringforastupidforum[/eluser] I think I get it now. OpenVBX devs did it completely backwards or I'm trying to do this backwards. So apparently, what I'm editing is a helper. Helpers cannot use $this. Controllers can. Which can call upon helpers. But helpers can be extended, yet not in the way that would allow for libraries to be loaded. Pffft. God help me. Having trouble getting Email library to load - El Forum - 11-23-2010 [eluser]ihateregisteringforastupidforum[/eluser] [quote author="dudeami0" date="1290577238"] Code: $this->load->library('email'); Debugger says Code: Fatal error: Using $this when not in object context in /OpenVBX/helpers/mail_helper.php on line 104 I'm trying to do it backwards. I need to probably load the email library in the controller that calls upon this helper. I hope the helper can then use $this->email->send();. No, I can't do that either. Code: Fatal error: Call to a member function library() on a non-object in /OpenVBX/models/vbx_user.php on line 202 Having trouble getting Email library to load - El Forum - 11-23-2010 [eluser]dudeami0[/eluser] Code: $ci =& get_instance(); // Place at the top of helper then replace all the $this in the helper with $ci. Having trouble getting Email library to load - El Forum - 11-23-2010 [eluser]ihateregisteringforastupidforum[/eluser] [quote author="dudeami0" date="1290578222"] Code: $ci =& get_instance(); // Place at the top of helper then replace all the $this in the helper with $ci.[/quote] That actually makes sense, since $ci is already instantiated in this particular function (by OpenVBX devs). However, it still complains about overloading ..bla bla bla. I hate it that I don't know what the heck that means. Code: Fatal error: Cannot assign by reference to overloaded object in /system/libraries/Model.php on line 69 Having trouble getting Email library to load - El Forum - 11-23-2010 [eluser]dudeami0[/eluser] Try Code: $ci = get_instance(); // Place at top of helper That should remove the overloaded object error. Having trouble getting Email library to load - El Forum - 11-23-2010 [eluser]ihateregisteringforastupidforum[/eluser] [quote author="dudeami0" date="1290579026"]Try Code: $ci = get_instance(); // Place at top of helper That should remove the overloaded object error.[/quote] It won't make a difference, it seems. Code: function openvbx_mail($recipient, $subject, $template, $maildata = array()) The error stays the same. Code: Fatal error: Cannot assign by reference to overloaded object in /system/libraries/Model.php on line 69 Having trouble getting Email library to load - El Forum - 11-23-2010 [eluser]ihateregisteringforastupidforum[/eluser] [quote author="dudeami0" date="1290579026"]Try Code: $ci = get_instance(); // Place at top of helper That should remove the overloaded object error.[/quote] I am very appreciative of your help and time. I will try to employ a Pear::Mail to send my emails. That I know how to work with. Have a wonderful night. Having trouble getting Email library to load - El Forum - 11-23-2010 [eluser]ihateregisteringforastupidforum[/eluser] A few questions, for coders/admins stumbling upon this post: 1. Why aren't you supposed to load and use a library within a helper? 2. Why aren't helpers getting the vars of the controller/model that called it in the first place? That seems to me like it could be very useful. |