Skip to contentSkip to navigationSkip to topbar

CodeIgniter


CodeIgniter comes with an email sending library built in. See more information on how to use CodeIgniter with SendGrid(link takes you to an external page).

(information)

Info

It is important to use the correct end of lines using "crlf" => "\r\n" and "newline" => "\r\n".

1
<?php
2
$this->load->library('email');
3
4
$this->email->initialize(array(
5
'protocol' => 'smtp',
6
'smtp_host' => 'smtp.sendgrid.net',
7
'smtp_user' => 'apikey',
8
'smtp_pass' => 'sendgridapikey',
9
'smtp_port' => 587,
10
'crlf' => "\r\n",
11
'newline' => "\r\n"
12
));
13
14
$this->email->from('your@example.com', 'Your Name');
15
$this->email->to('someoneexampexample@example.com');
16
$this->email->cc('another@another-example.com');
17
$this->email->bcc('them@their-example.com');
18
$this->email->subject('Email Test');
19
$this->email->message('Testing the email class.');
20
$this->email->send();
21
22
echo $this->email->print_debugger();
23
?>