---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/sendgrid/for-developers/sending-email/codeigniter#article
headline: CodeIgniter
description: Send email with CodeIgniter using SendGrid by configuring CodeIgniter's built-in email library to send over SendGrid's SMTP relay.
url: https://www.twilio.com/docs/sendgrid/for-developers/sending-email/codeigniter
inLanguage: en
dateModified: 2026-07-17T03:36:59.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# CodeIgniter

To send email with CodeIgniter and SendGrid, configure CodeIgniter's built-in email library to use SendGrid's SMTP relay. See the [CodeIgniter email library documentation](https://www.codeigniter.com/user_guide/libraries/email.html#using-the-email-library) for more information.

> \[!NOTE]
>
> Use the correct end of lines with "crlf" => "\r\n" and "newline" => "\r\n".

```php
<?php
$this->load->library('email');

$this->email->initialize(array(
  'protocol' => 'smtp',
  'smtp_host' => 'smtp.sendgrid.net',
  'smtp_user' => 'apikey',
  'smtp_pass' => 'sendgridapikey',
  'smtp_port' => 587,
  'crlf' => "\r\n",
  'newline' => "\r\n"
));

$this->email->from('your@example.com', 'Your Name');
$this->email->to('someoneexampexample@example.com');
$this->email->cc('another@another-example.com');
$this->email->bcc('them@their-example.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();

echo $this->email->print_debugger();
?>
```
