Mailjet and Cakephp code sample

integration with CakePhp's Email library

1) Use

 
<?php
 
    $this->Email->smtpOptions = array(
                    'timeout'=> '5',
                    'host' => 'ssl://in.mailjet.com',
                    'port'=> '465',
                    'username'=>'your_Mailjet_API_Key',
                    'password'=>'your_Mailjet_Secret_Key');
 
    $this->Email->delivery = 'smtp';
 
    $this->Email->from = 'You <your_sender@address.com>';
    $this->Email->to = 'Somebody <recipient@example.com>';
    $this->Email->subject = 'My first email by Mailjet';
 
    $this->Email->send('Hello from Mailjet & CakePHP 1.3 !');
?>
 

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.

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

2) More

http://cakephp.org