我正在尝试通过 Mandrill 发送一封带有 CakePHP 的电子邮件,但它只是旋转然后给出:
错误:连接超时
蛋糕\网络\异常\套接字异常
根据页面错误/堆栈跟踪,错误发生在vendor/cakephp/cakephp/src/Mailer/Transport/SmtpTransport.php line 206
:
if (!$this->_socket->connect()) {
从 /tmp/error.log:
2015-09-21 13:48:04 错误:[Cake\Network\Exception\SocketException] 连接超时请求 URL:/portal/users/add 堆栈跟踪:
#0 /home/user/public_html/user/mysitefolder/vendor/cakephp/cakephp/src/Mailer/Transport/SmtpTransport.php(206): Cake\Network\Socket->connect()
#1 /home/user/public_html/user/mysitefolder/vendor/cakephp/cakephp/src/Mailer/Transport/SmtpTransport.php(161): Cake\Mailer\Transport\SmtpTransport->_connect()
#2 /home/user/public_html/user/mysitefolder/vendor/cakephp/cakephp/src/Mailer/Email.php(1304): Cake\Mailer\Transport\SmtpTransport->send(对象(Cake\Mailer\Email))
#3 /home/user/public_html/user/mysitefolder/src/Controller/Portal/UsersController.php(92): Cake\Mailer\Email->send()
#4【内部函数】:App\Controller\Portal\UsersController->add()
#5 /home/user/public_html/user/mysitefolder/vendor/cakephp/cakephp/src/Controller/Controller.php(416): call_user_func_array(Array, Array)
#6 /home/user/public_html/user/mysitefolder/vendor/cakephp/cakephp/src/Routing/Dispatcher.php(114): Cake\Controller\Controller->invokeAction()
#7 /home/user/public_html/user/mysitefolder/vendor/cakephp/cakephp/src/Routing/Dispatcher.php(87): Cake\Routing\Dispatcher->_invoke(对象(App\Controller\Portal\UsersController))
#8 /home/user/public_html/user/mysitefolder/webroot/index.php(37): Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), Object(Cake\Network\Response))
#9 {主要}
在控制器中发送电子邮件:
use Cake\Mailer\Email;
// ...
$email = new Email('default');
$email->template('welcome', 'portal')
->from('myemail@gmail.com')
->to('myemail@gmail.com')
->send();
在我的 app.php 中:
'EmailTransport' => [
'default' => [
'className' => 'Smtp',
'host' => 'smtp.mandrillapp.com',
'port' => 587,
'timeout' => 30,
'username' => 'myusername',
'password' => 'mymandrillapikey', // Key
'client' => null,
'tls' => true, // have also tried false
],
],
'Email' => [
'default' => [
'transport' => 'default',
'from' => ['myemail@gmail.com' => 'My Name'],
'replyTo' => ['myemail@gmail.com' => 'My Name'],
'charset' => 'utf-8',
'headerCharset' => 'utf-8',
'log' => false,
'emailFormat' => 'html'
],
],
如果我只尝试标准的 PHP 邮件,它可以工作:
'EmailTransport' => [
'default' => [
'className' => 'Mail'
]
回顾: 我已经检查过 Mandrill,他们说他们不会阻止任何端口或类似的东西。我已经验证了我的主机(HostMonster),他们说端口是开放的,他们没有阻止任何东西。
我不知所措。即使不可能得到明确的答案,我也很感激任何帮助指出我正确的方向或一些想法,我什至可以调试这个问题。