Welcome Guest, Not a member yet? Register   Sign In
Problem using Email library in another Library

Hello, I've got a problem when using the CI Email library in another lib.
Here is my personal class :

class Custom_Email

    function Custom_Email(){
        $this->ci =& get_instance();

    function send($to, $subject, $message)
        $this->ci->email->from('[email protected]','Admin of mydomain.com');

        $header='...my html header here...';
        $footer='...my html footer here...';
        $message = $header.$message.$footer;

        $result = $this->ci->email->send();

        return $result;

When I try to use the send method from a controller, email is not sent whereas there is not error in print_debugger logs.

If I change
$this->ci->email->from('[email protected]','Admin of mydomain.com');
$this->ci->email->from('Admin of mydomain.com','Admin of mydomain.com');
(without @ in from() parameter) email is sent but the "from email and name" in the mail corresponds to my mail hoster's...

If I try

$this->email->from('[email protected]','Admin of mydomain.com');
$this->email->to('[email protected]');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
echo $this->email->print_debugger();

in the controller all is right.

Please help me, I can't understand !


What's your log telling you? It might benefit you to simply extend the Email class, although I see no reason why it shouldn't work from within another library.

seeing as the @ seems to be cauing the problem, try replaing it with '% 4 0' without the spaces, as that means @ (just a random idea)

Ok, I solved the problem, was due to using an email on a unexistant domain... With an [email protected] is OK.

Thank you for your help.


Theme © iAndrew 2016 - Forum software by © MyBB