I am using Gmail SMTP on local host and web server as well here is my code.

In email.php inside app/Config

public $gmail = array(
        'transport' => 'Smtp',
        'host' => 'ssl://smtp.gmail.com',
        'port' => 465,
        'timeout' => 30000,
        'username' => '[email protected]',
        'password' => 'yourpassword',
        'client' => null,
        'log' => true
        //'charset' => 'utf-8',
        //'headerCharset' => 'utf-8',
    );


And in any controller for sending emails-

$fromConfig = 'Sender Email';
$fromNameConfig = 'Sender Email';
$emailObj = new CakeEmail();
$emailObj->from(array( $fromConfig => $fromNameConfig));
$emailObj->sender(array( $fromConfig => $fromNameConfig));
$emailObj->subject('Mail Subject');
$body='Mail Body';
// we are using gmail config for sending mails through Gmail Smtp
$emailObj->config('gmail');
$result = $emailObj->send($body);


On Wed, Oct 24, 2012 at 11:12 AM, Vanja Dizdarević <
[email protected]> wrote:

> Sorry for not bumping old topics, but has anyone managed to send an email
> with CakeEmail and stmp.gmail.com?
>
> My settings:
> class EmailConfig {
> public $gmail = array(
>  'transport' => 'Smtp',
> 'from' => array('[email protected]' => 'Name'),
>  'host' => 'ssl://smtp.gmail.com',
> 'port' => 465,
>  'timeout' => 10,
> 'username' => '[email protected]',
>  'password' => 'youwishyouknew',
> 'client' => null,
> 'log' => true,
>  //'charset' => 'utf-8',
> //'headerCharset' => 'utf-8',
>                 'emailFormat' => 'html'
>  );
>
> My Controller code:
> function test_email(){
> $mail = new CakeEmail('gmail');
>                 $mail->addTo('[email protected]', 'User');
>                 $mail->from('[email protected]', 'User');
>                 $mail->subject('TESTING '.rand(10, 100));
>                 $mail->template('test', 'default');
>                 $return = $mail->send();
>                 debug($return);
>                 debug($mail);
>         die();
> }
> I keep getting Connection timeouts and Socket errors. Basically, the damn
> thing won't even connect, auth is never even touched. (neither dev, nor
> production machine..)
>
> I am using Google Apps on that domain (same domain as the production, not
> that it should matter...)
>
> I have checked for mod_openssl on the server.
> I have double checked the auth info.
> I am using Cake 2.2.1
>
> Is there something else I'm missing? Or should I just search for another
> email library?
>
> Thanks! Cheers!
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>



-- 
Chetan Varshney
Ektanjali Softwares Pvt Ltd

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to