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

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

Code:
class Custom_Email
{

    function Custom_Email(){
        $this->ci =& get_instance();
        $this->ci->load->library('Email');
    }

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

        $header='...my html header here...';
        $footer='...my html footer here...';
        $message = $header.$message.$footer;
        $this->ci->email->message($message);

        $result = $this->ci->email->send();
        log_message('debug',$this->ci->email->print_debugger());

        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
Code:
$this->ci->email->from('[email protected]','Admin of mydomain.com');
to
Code:
$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

Code:
$this->load->library('email');
$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.');
$this->email->send();
echo $this->email->print_debugger();

in the controller all is right.

Please help me, I can't understand !

Thx


Messages In This Thread
Problem using Email library in another Library - by El Forum - 05-25-2009, 06:06 AM
Problem using Email library in another Library - by El Forum - 05-25-2009, 06:30 AM
Problem using Email library in another Library - by El Forum - 05-25-2009, 06:36 AM
Problem using Email library in another Library - by El Forum - 05-25-2009, 11:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB