CodeIgniter Forums
Email class doesn't seem to work at all - 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: Email class doesn't seem to work at all (/showthread.php?tid=52334)



Email class doesn't seem to work at all - El Forum - 06-06-2012

[eluser]Dandy_andy[/eluser]
I cant seem to use any of the email class functions anywhere in my site. I have set up my localhost email system and I can send and receive emails fine through SMTP. However, when loading the email library, none of the functions seem to work and I get the error message:-

"Fatal error: Call to undefined method Email::from() in C:\xampp\testsite1\application\controllers\test.php on line 11"

The undefined method error applies to anything related to the email library and I can't figure out why. I've tried to autoload the 'email' library but that doesn't work.

I have also tried using the php mail() function and that works fine. Why doesn't the library 'email' class work? Any ideas?

Thanks in advance.




Email class doesn't seem to work at all - El Forum - 06-06-2012

[eluser]Abel A.[/eluser]
code?


Email class doesn't seem to work at all - El Forum - 06-06-2012

[eluser]Dandy_andy[/eluser]
Sorry, didn't include it as it's just a test controller at the moment:-

Code:
<?php

class Test extends CI_Controller {



function index(){

   $this->load->library('email');

   $this->email->from('support@localhost', 'test');
   $this->email->to('andy@localhost');
   $this->email->subject('Test');
   $this->email->message('testing message');
   $this->email->send();
   echo $this->email->print_debugger();

}

}

?>



Email class doesn't seem to work at all - El Forum - 06-06-2012

[eluser]Abel A.[/eluser]
Have you tried using real email addresses? like [email protected] instead of localhost.


Email class doesn't seem to work at all - El Forum - 06-06-2012

[eluser]Dandy_andy[/eluser]
Yep, tried that and still the same thing. The strange thing is, I can send mail through the controller using the php mail() function and they work fine on the localhost... I'm really scratching my head now and hoping it's something silly that I've overlooked.


Email class doesn't seem to work at all - El Forum - 06-06-2012

[eluser]Dandy_andy[/eluser]
Ok, figured it out. As usual it was me being a wally - I left a test file in the applications library folder entitled email.php and forgot to remove it! I'm learning so many lessons with CI, mainly that most mistakes are caused by my ignorance and tired brain!


Email class doesn't seem to work at all - El Forum - 06-06-2012

[eluser]Abel A.[/eluser]
are you on linux?

You might have to edit the sendmail path in the Email.php file in CI under system


Email class doesn't seem to work at all - El Forum - 06-06-2012

[eluser]Abel A.[/eluser]
Good to hear!