Solved

cant send email in cakephp

Posted on 2014-12-18
6
768 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
hulsebosch earned 500 total points
ID: 40507030
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
ID: 40508005
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
ID: 40508067
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
Optimum High-Definition Video Viewing and Control

The ATEN VM0404HA 4x4 4K HDMI Matrix Switch supports 4K resolutions of UHD (3840 x 2160) and DCI (4096 x 2160) with refresh rates of 30 Hz (4:4:4) and 60 Hz (4:2:0). It is ideal for applications where the routing of 4K digital signals is required.

 
LVL 4

Expert Comment

by:hulsebosch
ID: 40508115
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 43

Expert Comment

by:Rob
ID: 40508145
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
ID: 40520341
I dont need to email just yet  it seems so I dont need the question
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

623 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