How to send mail in codeigniter without smtp

In CodeIgniter, you can send mail without using SMTP by using the built-in email library and setting the mail transport to mail. Here's an example:

  1. First, make sure you have the email library loaded in your controller or model:
    $this->load->library('email');
  2. Set the mail transport to mail:
    $this->email->set_mailtype('text');
    $this->email->set_newline("\r\n");
    $this->email->from('[email protected]', 'Your Name');
    $this->email->to('[email protected]');
    $this->email->subject('Test Email');
    $this->email->message('This is a test email');
    $this->email->set_mailtransport('mail');
  3. Send the email:
    $this->email->send();

    This will send the email using the default mail transport, which is usually the PHP mail() function.

Note that you can also use other mail transports, such as sendmail or qmail, by setting the mailtransport property to the name of the transport you want to use.

Here's an example of sending an email using the sendmail transport:

$this->email->set_mailtransport('sendmail');

And here's an example of sending an email using the qmail transport:

$this->email->set_mailtransport('qmail');

Make sure to check the documentation for your specific mail transport to see if there are any additional configuration options or requirements.

Also, you can use the email library to send email using the swiftmailer library, which is a popular PHP library for sending emails. To use swiftmailer, you need to install it and then load it in your CodeIgniter application.

Here's an example of sending an email using swiftmailer:

$this->load->library('swiftmailer');
$mailer = new Swift_Mailer();
$message = Swift_Message::newInstance('Test Email');
$message->setFrom(array('[email protected]' => 'Your Name'));
$message->setTo(array('[email protected]'));
$message->setBody('This is a test email');
$mailer->send($message);

Note that you need to install swiftmailer and load it in your CodeIgniter application before you can use it.