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
#2

[eluser]TheFuzzy0ne[/eluser]
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.
#3

[eluser]Dam1an[/eluser]
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)
#4

[eluser]vxav[/eluser]
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.

Regards.




Theme © iAndrew 2016 - Forum software by © MyBB