CakePHP 3 Mail无法在实时服务器上运行:网络无法访问

时间:2018-05-22 10:07:41

标签: cakephp-3.x

当我将测试服务器的所有代码都放到实时服务器上时,发送电子邮件时出错了。

{ "message": "Network is unreachable", "url": "\/api\/users\/emailSheets", "code": 500, "file": "domainname.com/vendor\/cakephp\/cakephp\/src\/Network\/Socket.php", "line": 179 }

直播服务器有什么问题?

在我的app.php

'EmailTransport' => [
        'default' => [
            'className' => 'Mail',
            // The following keys are used in SMTP transports
            'host' => 'localhost',
            'port' => 25,
            'timeout' => 30,
            'username' => 'user',
            'password' => 'secret',
            'client' => null,
            'tls' => null,
            'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
        ],
        'gmail'=> [
          'host' => 'ssl://smtp.gmail.com',
          'port' => 465,
          'username' => 'my@gmail.com',  //your gmail address
          'password' => '123453',        //your gmail password
          'className' => 'Smtp',
          'log' => true,
          'context' => [
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name' => false,
                'allow_self_signed' => true
            ]
          ]
        ],
    ]

0 个答案:

没有答案