Configure Cakephp to send emails via gmail

Asked

Viewed 1,644 times

4

I’m trying to set up the to send emails through , I have already done some research and I have not yet succeeded in the result, someone could help me?

2 answers

4


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

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

You must create a new configuration 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 its configuration;

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 as per cakephp documentation: http://book.cakephp.org/2.0/en/core-utility-libraries/email.html

  • I’ll try it, thanks.

  • 1

    Don’t forget to put the config in the class when calling $Email = new Cakeemail(); $Email->config('gmail');

Browser other questions tagged

You are not signed in. Login or sign up in order to post.