![]() |
Message: Call to a member function email->from() on string - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Message: Call to a member function email->from() on string (/showthread.php?tid=70412) |
Message: Call to a member function email->from() on string - kylmiko - 04-05-2018 Please help... I have 2 controllers first controller is home and my sendemail method is working and no problem at all but when I copy the same method to user controller it keeps me getting an error "Message: Call to a member function email->from() on string" heres my method... public function sendEmail($email,$link){ $message = "Hi" $subject = "hello message"; $this->load->library('email'); $this->load->helper(array('email')); $this->email->from('[email protected]', 'Email'); $this->email->to($email); $this->email->subject($subject); $this->email->message($message); $this->email->set_mailtype("html"); if($this->email->send()) return true; else return false; } I am looking forward to your positive response thank you so much... RE: Message: Call to a member function email->from() on string - php_rocs - 04-05-2018 @kylmiko, What values are you expecting for $this->email->from()? RE: Message: Call to a member function email->from() on string - dave friend - 04-05-2018 (04-05-2018, 09:56 AM)php_rocs Wrote: @kylmiko, Looks to me like he is using the string literals '[email protected]' and 'Email' in the call. PHP Code: $this->email->from('[email protected]', 'Email'); RE: Message: Call to a member function email->from() on string - php_rocs - 04-05-2018 @Dave friend, I am trying to ask what are the specific values that the from method is expecting. It could be a case of wrong values that are causing the error. RE: Message: Call to a member function email->from() on string - Paradinight - 04-05-2018 (04-05-2018, 08:00 AM)kylmiko Wrote: Please help... https://forum.codeigniter.com/thread-70394-post-352779.html#pid352779 RE: Message: Call to a member function email->from() on string - dave friend - 04-05-2018 (04-05-2018, 10:24 AM)php_rocs Wrote: @Dave friend, The method CI_Email::from() accepts three arguments, all three are strings, the second and third arguments are optional. Read the docs. Nothing happens in the method that would produce the error described. That error message would seem to indicate that the variable $this->email is a string and not an instance of the CI_Email class. How that occurs is not determinable in the code the OP provides. RE: Message: Call to a member function email->from() on string - php_rocs - 04-05-2018 @kylmiko, I'm wondering if you even need this helper when you have already loaded the library [ $this->load->helper(array('email')); ]. This may be causing a conflict. @Dave friend, I did a quick browse and didn't know if he was using a custom library. RE: Message: Call to a member function email->from() on string - kylmiko - 04-09-2018 (04-05-2018, 12:05 PM)dave friend Wrote:(04-05-2018, 10:24 AM)php_rocs Wrote: @Dave friend, RE: Message: Call to a member function email->from() on string - InsiteFX - 04-10-2018 Did you try? PHP Code: $this->email->initialize($config); |