Solved

cant send email in cakephp

Posted on 2014-12-18
6
605 Views
Last Modified: 2014-12-28
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',
);
0
Comment
Question by:jagguy
  • 3
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
hulsebosch earned 500 total points
Comment Utility
How did you configure the smtp settings?

class EmailConfig {
    public $gmail = array(
        'host' => 'smtp.gmail.com',
        'port' => 465,
        'username' => 'my@gmail.com',
        'password' => 'secret',
        'transport' => 'Smtp',
        'tls' => true
    );
}
0
 

Author Comment

by:jagguy
Comment Utility
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.
0
 

Author Comment

by:jagguy
Comment Utility
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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 4

Expert Comment

by:hulsebosch
Comment Utility
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.
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
Comment Utility
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
0
 

Author Comment

by:jagguy
Comment Utility
I dont need to email just yet  it seems so I dont need the question
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now