Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP-2.0: How can i send email from a gmail account using CakEmail and SMTP setting?

I'm trying to send email from a gmail account using CakEmail and SMTP settings .

It would be nice if someone tell the process step by step what to do .

I have added the following in app/Config/email.php=>

<?php
class EmailConfig {
    public $smtp = array(
        'host' => 'ssl://smtp.gmail.com',
        'port' => 465,
        'username' => '[email protected]',
        'password' => 'secret'
    );
}

Now how can i send email to any email account from "[email protected]" ?

It's CakePHP-2.0

like image 301
shibly Avatar asked Oct 27 '11 11:10

shibly


2 Answers

From the docs:

You can configure SSL SMTP servers, like GMail. To do so, put the 'ssl://' at prefix in the host and configure the port value accordingly. Example:

<?php
class EmailConfig {
    public $gmail = array(
        'host' => 'ssl://smtp.gmail.com',
        'port' => 465,
        'username' => '[email protected]',
        'password' => 'secret'
    );
}

http://book.cakephp.org/2.0/en/core-utility-libraries/email.html?highlight=cakeemail#CakeEmail

like image 81
RichardAtHome Avatar answered Sep 30 '22 00:09

RichardAtHome


The right configuration is:

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

So, don't forget the transport element.

like image 44
Dirk Avatar answered Sep 30 '22 00:09

Dirk