0
我無法從我的cakephp 3網站發送郵件。我嘗試了一個simiple testmail.php文件,我收到了電子郵件,但是當我嘗試在app.php上設置相同的用戶名和密碼時,我正在連接超時。錯誤:[Cake Network Exception SocketException]連接超時
Error: [Cake\Network\Exception\SocketException] Connection timed out
這是1and1.com。在本地主機上設置時,我可以發送郵件。
什麼是錯的:
這裏是error.log中:
2017-08-24 14:05:09 Error: [Cake\Network\Exception\SocketException] Connection timed out
Request URL: /contactus/
Referer URL: https://example.com/
Stack Trace:
#0 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Mailer/Transport/SmtpTransport.php(207): Cake\Network\Socket->connect()
#1 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Mailer/Transport/SmtpTransport.php(162): Cake\Mailer\Transport\SmtpTransport->_connect()
#2 /homepages/30/d665828522/htdocs/app/vendor/cakephp/debug_kit/src/Mailer/Transport/DebugKitTransport.php(79): Cake\Mailer\Transport\SmtpTransport->send(Object(Cake\Mailer\Email))
#3 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Mailer/Email.php(1344): DebugKit\Mailer\Transport\DebugKitTransport->send(Object(Cake\Mailer\Email))
#4 /homepages/30/d665828522/htdocs/app/src/Controller/UsersController.php(335): Cake\Mailer\Email->send()
#5 /homepages/30/d665828522/htdocs/app/src/Controller/UsersController.php(113): App\Controller\UsersController->_sendVerificationCode(Object(Cake\ORM\Entity))
#6 [internal function]: App\Controller\UsersController->ajaxRegister()
#7 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Controller/Controller.php(435): call_user_func_array(Array, Array)
#8 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(121): Cake\Controller\Controller->invokeAction()
#9 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(95): Cake\Http\ActionDispatcher->_invoke(Object(App\Controller\UsersController))
#10 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Http/BaseApplication.php(83): Cake\Http\ActionDispatcher->dispatch(Object(Cake\Network\Request), Object(Cake\Network\Response))
#11 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Http\BaseApplication->__invoke(Object(Zend\Diactoros\ServerRequest), Object(Zend\Diactoros\Response), Object(Cake\Http\Runner))
#12 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Routing/Middleware/RoutingMiddleware.php(62): Cake\Http\Runner->__invoke(Object(Zend\Diactoros\ServerRequest), Object(Zend\Diactoros\Response))
#13 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Routing\Middleware\RoutingMiddleware->__invoke(Object(Zend\Diactoros\ServerRequest), Object(Zend\Diactoros\Response), Object(Cake\Http\Runner))
#14 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Routing/Middleware/AssetMiddleware.php(88): Cake\Http\Runner->__invoke(Object(Zend\Diactoros\ServerRequest), Object(Zend\Diactoros\Response))
#15 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Routing\Middleware\AssetMiddleware->__invoke(Object(Zend\Diactoros\ServerRequest), Object(Zend\Diactoros\Response), Object(Cake\Http\Runner))
#16 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Error/Middleware/ErrorHandlerMiddleware.php(81): Cake\Http\Runner->__invoke(Object(Zend\Diactoros\ServerRequest), Object(Zend\Diactoros\Response))
#17 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Error\Middleware\ErrorHandlerMiddleware->__invoke(Object(Zend\Diactoros\ServerRequest), Object(Zend\Diactoros\Response), Object(Cake\Http\Runner))
#18 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Http/Runner.php(51): Cake\Http\Runner->__invoke(Object(Zend\Diactoros\ServerRequest), Object(Zend\Diactoros\Response))
#19 /homepages/30/d665828522/htdocs/app/vendor/cakephp/cakephp/src/Http/Server.php(90): Cake\Http\Runner->run(Object(Cake\Http\MiddlewareQueue), Object(Zend\Diactoros\ServerRequest), Object(Zend\Diactoros\Response))
#20 /homepages/30/d665828522/htdocs/app/webroot/index.php(37): Cake\Http\Server->run()
#21 {main}
我試過的設置本地主機正常工作時,我上傳相同的服務器,它不工作。 – TheDevMan
也許在你的服務器上有防火牆。如果它是一個Linux,嘗試ping服務器,如果它回答了嘗試用telnet手動連接到你的smtp服務器:「** telnet [地址或你的服務器] [端口,25/465或587] **」。在窗口上,您可以使用** putty **來檢查連接。 – Benfarhat
正如我之前所說,沒有防火牆問題,因爲testmail.php工作正常與SMTP 25/465/587都工作。 – TheDevMan