jeudi 7 juillet 2016

Getting an Error 500 when sending an email in Codeigniter

I am having trouble with CodeIgniter. I have preloaded the email configuration but when I try to send an email using a function in the controller, I get an error 500. Not sure what it is. Please help!

public function regvalidation()
{
    $this->load->library('form_validation');

    $this->form_validation->set_rules('email','email','required|trim|valid_email|is_unique[user_admin.username]');

    $this->form_validation->set_rules('password','Password','required|trim');
    $this->form_validation->set_rules('c_password','Confirm Password','required|trim|matches[password]');


    if ($this->form_validation->run())
    {

        $this->load->library('email');
        $key = md5(uniqueid());

        //echo $this->input->post('email');

        $this->email->from('edgemaster@edge.xyz','Edge Master');
        $this->email->to($this->input->post('email'));
        $this->email->subject("EDGE | Confirm your account");

        $message = "<p>Thank you for signing up</p>";
        $message .= "<p><a href='".base_url()."main/register_user/".$key.">Click here</a>to confirm your account.</p>";

        $this->email->message($message);

        $this->email->send();

        if ($this->email->send())
        {
            echo "This email has been sent.";
        }
        else
        {
            echo "failed.";
        }
    }

    else
    {
        $this->load->view('signup.php');
    }
}

Aucun commentaire:

Enregistrer un commentaire