Skip to content

Instantly share code, notes, and snippets.

@SendGrid-Demos
Created July 19, 2012 22:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SendGrid-Demos/3147183 to your computer and use it in GitHub Desktop.
Save SendGrid-Demos/3147183 to your computer and use it in GitHub Desktop.
SendGrid + CodeIgniter
<?php
/* application/config/email.php */
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
|--------------------------------------------------------------------------
| SendGrid Setup
|--------------------------------------------------------------------------
|
| All we have to do is configure CodeIgniter to send using the SendGrid
| SMTP relay:
*/
$config['protocol'] = 'smtp';
$config['smtp_port'] = '587';
$config['smtp_host'] = 'smtp.sendgrid.net';
$config['smtp_user'] = 'your_sendgrid_username';
$config['smtp_pass'] = 'your_sendgrid_password';
<?php
/* application/controllers/welcome.php */
public function index()
{
$this->load->library('email');
$this->email->from('john.doe@example.com', 'John');
$this->email->to('jane.doe@example.com');
$this->email->subject('Test Email using SendGrid');
$this->email->message('This email was delivered by your friends at SendGrid');
$this->email->send();
$this->load->view('welcome_message');
}
@Indwr
Copy link

Indwr commented Jun 14, 2019

Can't work This Code

Showing This error "No direct script access allowed".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment