Follow given below steps:

Step 1

Download Mailchimp API File from: CodeIgniter-Library-for-MailChimp-API-v1.3.

Step 2


After then, Place MCAPI.php in given path: CodeIgniter\application\libraries- file name is MCAPI.php.

Step 3

Add mcapi.php in CodeIgniter\application\config

  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. // You MailChimp API Key
  3. // Obtained by logging into your MailChimp account and navigating to 'Account > API Keys and Info'
  4. $config['mcapi_apikey'] = '**********'; /// mailchimp apikey
  5. $config['mcapi_secure'] = false;
Step 4

Add content in CodeIgniter\application\models - your usermodel.php(your file).
  1. $this->load->library('mcapi');
  2. $listID = '*********' ; //your mailchimp list id
  3. $retval = $this->mcapi->listSubscribe($listID, $emailAddress);
  4. if ($this->mcapi->errorCode) {
  5. echo "Unable to subscribe email using listSubscribe()!";
  6. echo "\n\tCode=".$this->mcapi->errorCode;
  7. echo "\n\tMsg=".$this->mcapi->errorMessage."\n";
  8. }

  9. else {
  10. echo $emailAddress." added successfully\n";
  11. }