Skip to content

Instantly share code, notes, and snippets.

@kadavre
Last active October 25, 2019 11:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kadavre/6965796 to your computer and use it in GitHub Desktop.
Save kadavre/6965796 to your computer and use it in GitHub Desktop.
Send mail with cakephp using gmail.
public $gmail = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'votreidentifiant@gmail.com',
'password' => 'motdepasse',
'transport' => 'Smtp',
'timeout' => 30
);
$email = new CakeEmail('gmail');
$email->from('votreidentifiant@gmail.com')
->to('contact@grafikart.fr')
->subject('Merci !')
->send("Hello Grafikart");
@ParitoshBh
Copy link

For CakePHP 3 something like the following would work,

'EmailTransport' => [
        'default' => [
            'className' => 'Smtp',
            // The following keys are used in SMTP transports
            'host' => 'ssl://smtp.gmail.com',
            'port' => 465,
            'timeout' => 30,
            'username' => 'username@domain.com',
            'password' => 'your_password',
        ],
    ],

Needless to say this would go in config\app.php

@misdotdot
Copy link

i have not smtp credential, is it mendetory (www.examsdetails.com) smtp credentials in cakephp version 3

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