0

I have looked through almost all existing threads, but I still can't find the problem, so I decided post a new one.

I have code that is running on my live server and the email function is working perfectly fine. It was setup by a contractor and he left no documentation on how to setup CakePHP.

I need to setup my staging server to work exactly the same as the live server. I think I have everything working, except for the email functions. Since I am running exactly the same code on both servers, I am positive that I have missed installing something or setting up configuration on my staging server.

So, what is the framework/module/library needed for CakeEmail? What is the configuration needed for it?

I am running at CakePHP 2.3.4

Here's my code snippet:

App::uses('CakeEmail', 'Network/Email');
$emailTest = new CakeEmail('default');
            $emailTest->to('MyEmail@gmail.com');
            $emailTest->from(array('me@example.com' => 'My Site'));
            $emailTest->subject('About');
            try {
                $emailTest->send('Hey');
            }
            catch (SocketException $e) {
                echo("Exception: " . $e->getMessage() . "\r\n");
                echo("File: " . $e->getFile() . "\r\n");
                echo("Line: " . $e->getLine() . "\r\n");
                echo("Trace: " . $e->getTraceAsString() . "\r\n");
            }

In email.php:

public $default = array(
    'transport' => 'Mail',
    'from' => 'notification@MySite.com',
    // 'charset' => 'utf-8',
    // 'headerCharset' => 'utf-8',
);

And I am getting this stack trace:

Exception: Could not send email. File: /var/www/MySite/lib/Cake/Network/Email/MailTransport.php Line: 70 Trace: 0 /var/www/MySite/lib/Cake/Network/Email/MailTransport.php(47): MailTransport->_mail('staging@gmail.c...', 'hsbsv vdbeh lik...', 'hsbsv vdbeh lik...', 'From: MySite...', NULL)

1 /var/www/MySite/lib/Cake/Network/Email/CakeEmail.php(1071): MailTransport->send(Object(CakeEmail))

2 /var/www/MySite/app/Model/Notification.php(238): CakeEmail->send('hsbsv vdbeh lik...')

3 [internal function]: Notification->afterSave(true, Array)

4 /var/www/MySite/lib/Cake/Event/CakeEventManager.php(246): call_user_func_array(Array, Array)

5 /var/www/MySite/lib/Cake/Model/Model.php(1772): CakeEventManager->dispatch(Object(CakeEvent))

6 /var/www/MySite/app/Controller/CommentsController.php(160): Model->save(Array)

7 [internal function]: CommentsController->add()

8 /var/www/MySite/lib/Cake/Controller/Controller.php(486): ReflectionMethod->invokeArgs(Object(CommentsController), Array)

9 /var/www/MySite/lib/Cake/Routing/Dispatcher.php(187): Controller->invokeAction(Object(CakeRequest))

10 /var/www/MySite/lib/Cake/Routing/Dispatcher.php(162): Dispatcher->_invoke(Object(CommentsController), Object(CakeRequest), Object(CakeResponse))

11 /var/www/MySite/app/webroot/index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))

12 {main}

Oldskool
  • 34,211
  • 7
  • 53
  • 66
nigong
  • 1,727
  • 3
  • 19
  • 33

0 Answers0