www.webdeveloper.com
Results 1 to 4 of 4

Thread: Call to undefined method EmailComponent

  1. #1
    Join Date
    May 2009
    Posts
    17

    Call to undefined method EmailComponent

    Hi all!

    I supposed that I will ask on this forum again but I didn't know it will be so soon..
    So, when I register on my site as a new user this error is occuring:
    Fatal error: Call to undefined method EmailComponent::__() in C:\wamp2\www\app\controllers\components\email.php on line 329

    I checked that file but with my knowledge I can't fix it. I'm adding attachment cause this code is longer than 10000 signs. Thanks for helping me out.
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2008
    Posts
    2,477
    Why are you moving EmailComponent to your app directory? It's a core cake library and should stay where it is unless you are intending to override it. To use it you just need to add:

    PHP Code:
    public $components = array('Email'); 
    to your controller.

    EDIT: realised I didn't answer your question, it seems you are setting $this->EmailComponent->delivery to an empty string in your controller somewhere, but if you need help you really need to post all the involved code otherwise all we can do is guess. Make sure EmailComponent::delivery is either set to mail, smtp or debug and you should be good though.
    Last edited by Mindzai; 05-08-2009 at 08:31 PM.

  3. #3
    Join Date
    May 2009
    Posts
    17
    In my config.php I have this:

    PHP Code:
    'Email' => array(
                
    'delivery' => 'smtp',
                
    'sendAs'   => 'both',
                
    'host'     => '',
                
    'port'     => 25,
                
    'timeout'  => 60,
                
    'username' => '',
                
    'password' => ''
            
    ), 
    I've filled it like that and it's not working:

    PHP Code:
    'Email' => array(
                
    'delivery' => 'smtp',
                
    'sendAs'   => 'both',
                
    'host'     => 'www.o2.pl',
                
    'port'     => 25,
                
    'timeout'  => 60,
                
    'username' => 'my_username',
                
    'password' => 'my_password'
            
    ), 
    I'm not really sure what should be in 'host' section though.. I assume that somewhere I need to put my email's provider address but I don't know if "host" is really the place for it.

  4. #4
    Join Date
    Nov 2008
    Posts
    2,477
    I'm not sure you're working with cake in the right way. config.php is a core file and should not be changed. To configure the email component you need to execute the following in a controller:

    PHP Code:
    $this->Email->smtpOptions = array(
            
    'port'=>'25'
            
    'timeout'=>'30',
            
    'host' => 'your.smtp.server',
            
    'username'=>'your_smtp_username',
            
    'password'=>'your_smtp_password');

        
    /* Set delivery method */
        
    $this->Email->delivery 'smtp';

        
    /* Do not pass any args to send() */
        
    $this->Email->send();

        
    /* Check for SMTP errors. */
        
    $this->set('smtp-errors'$this->Email->smtpError); 
    Note that host is your smtp server, which will probably at a smtp rather than www subdomain (ie smtp.o2.pl), but you'll need to check that with your provider.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles