Sending plain e-mails with CodeIgniter Email

It's always useful to be able to send e-mails and CodeIgniter comes with an excellent library for sending e-mails. There are a few recipes in this chapter, which deal with sending e-mails. However, this is the basic Hello World type example that is very simple.

How to do it...

A simple way to send plain e-mails using CodeIgniter Email is as follows:

  1. Create a file email.php at path/to/codeigniter/application/controllers/.
  2. Add the following code to the controller file email.php:
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Email extends CI_Controller { function __construct() { parent::__construct(); $this->load->helper('url'); $this->load->library('email'); } public function ...

Get CodeIgniter 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.