Activation mail is not sent in php codigniter

A common issue!

In CodeIgniter, the activation mail is not sent by default. You need to configure it manually. Here's a step-by-step guide to help you resolve this issue:

Step 1: Enable email sending

In your config.php file, set the email_type variable to phpmailer:

$config['email_type'] = 'phpmailer';

Step 2: Configure PHPMailer

Create a new file called phpmailer.php in the application/libraries directory. This file will contain the PHPMailer configuration.

In phpmailer.php, add the following code:

<?php

class PHPMailer {
    public $Host = 'your_smtp_host';
    public $Username = 'your_smtp_username';
    public $Password = 'your_smtp_password';
    public $Port = 587; // or 25, 465, etc.
    public $SMTPSecure = 'tls'; // or 'ssl', 'none', etc.
}

Replace the placeholders with your actual SMTP server settings.

Step 3: Load the PHPMailer library

In your autoload.php file, add the following line:

$autoload['libraries'] = array('phpmailer');

Step 4: Configure the email settings

In your config/email.php file, add the following code:

<?php

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

Replace the placeholders with your actual SMTP server settings.

Step 5: Send the activation email

In your controller, use the email library to send the activation email:

<?php

class Your_controller extends CI_Controller {
    public function activate_account() {
        $this->load->library('email');
        $this->email->from('your_email_from', 'Your Name');
        $this->email->to($this->input->post('email'));
        $this->email->subject('Account Activation');
        $this->email->message('Hello, please click this link to activate your account: <a href="'. base_url(). 'activate/'. $this->input->post('activation_code'). '">Activate</a>');
        $this->email->send();
    }
}

Make sure to replace the placeholders with your actual email settings and activation code.

That's it! With these steps, you should be able to send the activation email using CodeIgniter.