Mailjet and Codeigniter code sample

integration with Codeigniter's Email library

1) Configuration

Create a file in config/email.php and edit it :

 
<?php
 
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://in.mailjet.com';
$config['smtp_port'] = '465';
$config['smtp_user'] = 'your_Mailjet_API_Key';
$config['smtp_pass'] = 'your_Mailjet_Secret_Key';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['newline'] = "\r\n";
 
?>
 

You have to edit only these configuration parameters :

- 'smtp_host' : ssl://in.mailjet.com if you want use SSL secure mode, tls://in.mailjet.com for TLS secure mode or in.mailjet.com for no encryption.
- 'smtp_port' : the port used to transport your emails (465, 587, 588, 25)
- 'smtp_user' : it's your API Key
- 'smtp_pass' : it's your Secret Key.

Others parameters must not be edited.

2) Use

In a controller :

 
$this->load->library('email');
 
$this->email->from('your_sender@address.com', 'You');
$this->email->to('recipient@example.com');
$this->email->subject('My first email by Mailjet');
$this->email->message('Hello from Mailjet & CodeIgniter !');
 
$this->email->send();
 

Do not forget to edit your sender address "from".

3) More

http://codeigniter.com