I'm currently rewriting a client's web application using cakephp. One of the pages requires sending the data in a form to the company in an email. I'm having problems with this in my development environment:
-- - Ubuntu 14.10
- Apache2/PHP with all the normal libraries like lib_php, mod_rewrite, etc
- PHP 5.5
- CakePHP 2.5.4
After poking about a bit on the web, I've seen that I have to load lib_openssl and that I should include the following line in my php.ini file. So in /etc/php5/apache2/php.ini I've added the recommended line to the Dynamic Extensions section:
extension=php_openssl.so
I'm not sure if this is correct because Ubuntu includes php_openssl via gnutls. However, I don't know how to test this.
I've created an email.php file under app/Config with the following class definition:
class EmailConfig {
public $gmail = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'myusername@gmail.com',
'password' => 'mypassword',
'transport' => 'Smtp',
);
}
The username and password are copied from Thunderbird, so should be OK.
Finally, I set up a test page under app/View/Pages, called email-tester.ctp containing the code:
<?php
App::uses('CakeEmail', 'Network/Email');
$Email = new CakeEmail();
$Email->from(array('myusername@gmail.com' => 'My Gmail Address'))
->to('myemail@myemailprovider.con')
->subject('About')
->send('My message');
?>
<p>Email sent...</p>
When I try to open this page at localhost/myproject/pages/email-tester I get an error message as follows:
Error: An Internal Error Has Occurred.
Stack Trace
- CORE/Cake/Network/Email/MailTransport.php line 51 → MailTransport->_mail(string, string, string, string, null)
- CORE/Cake/Network/Email/CakeEmail.php line 1158 → MailTransport->send(CakeEmail)
- APP/View/Pages/email-tester.ctp line 8 → CakeEmail->send(string)
- CORE/Cake/View/View.php line 948 → include(string)
- CORE/Cake/View/View.php line 910 → View->_evaluate(string, array)
- CORE/Cake/View/View.php line 471 → View->_render(string)
- CORE/Cake/Controller/Controller.php line 954 → View->render(string, null)
- APP/Controller/PagesController.php line 69 → Controller->render(string)
- [internal function] → PagesController->display(string)
- CORE/Cake/Controller/Controller.php line 490 → ReflectionMethod->invokeArgs(PagesController, array)
- CORE/Cake/Routing/Dispatcher.php line 191 → Controller->invokeAction(CakeRequest)
- CORE/Cake/Routing/Dispatcher.php line 165 → Dispatcher->_invoke(PagesController, CakeRequest)
- APP/webroot/index.php line 108 → Dispatcher->dispatch(CakeRequest, CakeResponse)
If anyone can decode this for me, or give me some idea as to what I should try next, I'd be very grateful.
Thanks in advance
Peter
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment