CodeIgniter
CodeIgniter comes with an email sending library built in. See more information on how to use CodeIgniter with SendGrid.
It is important to use the correct end of lines using "crlf" => "\r\n" and "newline" => "\r\n".
<?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();
?>
Need some help?
We all do sometimes. Get help now from the Twilio SendGrid Support Team.
Running into a coding hurdle? Lean on the wisdom of the crowd by browsing the SendGrid tag on Stack Overflow or visiting Twilio's Stack Overflow Collective.