How to find mail is sent or not in codeigniter

In CodeIgniter, you can use the email library to send and track emails. To find out if an email has been sent or not, you can use the send() method and check the return value.

Here's an example:

<?php

class My_controller extends CI_Controller {

    public function send_email() {
        $this->load->library('email');

        $config = array(
            'protocol' => 'smtp',
            'smtp_host' => 'your_smtp_host',
            'smtp_port' => 587,
            'smtp_user' => 'your_smtp_username',
            'smtp_pass' => 'your_smtp_password',
            'mailtype' => 'html',
            'charset' => 'utf-8'
        );

        $this->email->initialize($config);

        $this->email->from('your_from_email', 'Your Name');
        $this->email->to('recipient_email');
        $this->email->subject('Test Email');
        $this->email->message('This is a test email');

        if ($this->email->send()) {
            echo "Email sent successfully!";
        } else {
            echo "Error sending email: ". $this->email->print_debugger();
        }
    }
}

In this example, the send_email() method loads the email library, sets up the email configuration, and sends the email using the send() method. The send() method returns a boolean value indicating whether the email was sent successfully or not.

If the email is sent successfully, the method will output "Email sent successfully!". If there's an error sending the email, the method will output an error message with the debug information.

You can also use the print_debugger() method to get more detailed information about the email sending process, including any errors that may have occurred.

Alternatively, you can use the send_and_log() method, which sends the email and logs the result in the database. This method returns a boolean value indicating whether the email was sent successfully or not.

if ($this->email->send_and_log()) {
    echo "Email sent successfully!";
} else {
    echo "Error sending email: ". $this->email->print_debugger();
}

Note that the send_and_log() method requires you to have the email_log table set up in your database, and the email library configured to use it.