Link to home
Start Free TrialLog in
Avatar of jagguy
jagguyFlag for Australia

asked on

cant send email in cakephp

Hi,

I cant send a email from my localhost xampp/win7
I dont get an error , I just get nothing

I set up the email and also config. I read the docs and couldnt see anything on this.

http://book.cakephp.org/2.0/en/core-utility-libraries/email.html

  $Email = new CakeEmail();
                    $Email->config('smtp')
             ->from('email@gmail.com')
           ->to('jagguy999@gmail.com')
             ->subject('Test')
             ->send($message);


      public $smtp = array(
    'transport' => 'Smtp',
    'from' => array('site@localhost' => 'My Site'),
    'host' => 'localhost',
    'port' => 25,
    'timeout' => 30,
    'username' => 'user',
    'password' => 'secret',
    'client' => null,
    'log' => false,
    //'charset' => 'utf-8',
    //'headerCharset' => 'utf-8',
);
ASKER CERTIFIED SOLUTION
Avatar of Thierry Hulsebosch
Thierry Hulsebosch
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jagguy

ASKER

Hi,

Please if your going to reply with some code that I am having problems with then can you explain this better.
I already gave an example of this file in app/Config/email.php and you gave another example of a file which the docs say isnt required. Can you see how I am not getting anywhere?

    public $smtp = array(
    'transport' => 'Smtp',
    'from' => array('site@localhost' => 'My Site'),
    'host' => 'localhost',
    'port' => 25,
    'timeout' => 30,
    'username' => 'user',
    'password' => 'secret',
    'client' => null,
    'log' => false,
    //'charset' => 'utf-8',
    //'headerCharset' => 'utf-8',
);

It is not required to create app/Config/email.php, CakeEmail can be used without it and use respective methods to set all configurations separately or load an array of configs.
Avatar of jagguy

ASKER

This isnt working and I need help as I cant fund help from the docs.
I set up the settings and in the config file I have


public $gmail = array(
    'from' => array('jagguy999@gmail.com' => 'Aptutoring'),      
    'host' => 'localhost',
        'port' => 25,
        'username' => 'my@gmail.com',  //I changed the name but he email/password is real gmail account
        'password' => 'test',
       // 'transport' => 'Smtp'
    );
   
    public $smtp = array(
    'transport' => 'Smtp',
   // 'from' => array('site@localhost' => 'My Site'),
       'from' => array('jagguy999@gmail.com' => 'My Site'),      
    'host' => 'localhost',
    'port' => 25,
    'timeout' => 30,
    'username' => 'user',
    'password' => 'secret',
    'client' => null,
    'log' => false,
    //'charset' => 'utf-8',
    //'headerCharset' => 'utf-8',
);


No connection could be made because the target machine actively refused it.
Jagguy,

PHP has, nore is an smtp server of its own.
Therefore you will need to present one, as in the sample I presented to you.

Please note, that Gmail is just a sample of which I am pretty sure will not work as well.
You can try this setting, using the smtp settings from your own provider.

  'host' => 'localhost', will not send out your mail.
Do you have an email server setup?  You are using localhost, meaning you are trying to send an email using your webserver.

try using smtp.gmail.com instead of localhost
Avatar of jagguy

ASKER

I dont need to email just yet  it seems so I dont need the question