Configure CakePHP to send emails through gmail

4

I'm trying to set up to send emails via < I have already done some research and have not yet had success in the result, someone could you help me?

    
asked by anonymous 03.03.2014 / 16:29

2 answers

3

In your app/Config/email.php file you will need to create the EmailConfig class.

The file app/Config/email.php.default is an example of how it should look.

You should create a new setting called with the following code

public $gmail = array(
    'host' => 'ssl://smtp.gmail.com',
    'port' => 465,
    'username' => '[email protected]', // seu email no gmail
    'password' => 'senha', // sua senha no gmail
    'transport' => 'Smtp'
);

For connections you will need to include 'tls' => true in your configuration;

    
03.03.2014 / 16:49
4

If your cakephp is 2.3.0 or higher use:

public $gmail = array(
    'host' => 'smtp.gmail.com',
    'port' => 465,
    'username' => '[email protected]',
    'password' => 'secret',
    'transport' => 'Smtp',
    'tls' => true
);

See that it uses tls = > true, for previous version use:

public $gmail = array(
    'host' => 'ssl://smtp.gmail.com',
    'port' => 465,
    'username' => '[email protected]',
    'password' => 'secret',
    'transport' => 'Smtp'
);

This in the /app/Config/email.php class according to cakephp documentation: link

    
03.03.2014 / 17:15