2015-05-03 147 views
4

我正在配置我的應用程序從我的smtp服務器發送郵件,該郵件位於1and1的遠程主機中。 我不知道如果我失去了一些東西:從SMTP遠程服務器發送電子郵件CakePHP 3

  • 我已經改變了我app.php通過我的託管服務提供商給出的值:

    'EmailTransport' => [ 
        'default' => [ 
         'className' => 'Mail', 
         'host' => 'smtp.1and1.com', 
         'port' =>'587' , 
         'timeout' => 30, 
         'username' => '[email protected]', 
         'password' => '******', 
         'client' => null, 
         'tls' => null, 
        ], 
    ], 
    
    'Email' => [ 
        'default' => [ 
         'transport' => 'default', 
         'from' => '@localhost', 
         //'charset' => 'utf-8', 
         //'headerCharset' => 'utf-8', 
        ], 
    ], 
    

在這裏,您可以請參閱由我的託管服務提供商提供的連接到他們的smtp服務器的說明。

smtp requiere comfig

我沒有得到任何結果。 有沒有人有想法我可能會錯過什麼?

回答

1

我得到它的工作設置類名爲'郵件'和其餘的參數作爲默認。請做如下:

'EmailTransport' => [ 
     'default' => [ 
      'className' => 'Mail', 
      // The following keys are used in SMTP transports 
      'host' => 'localhost', 
      'port' => 25, 
      'timeout' => 30, 
      'username' => 'user', 
      'password' => 'secret', 
      'client' => null, 

     ], 
    ], 
+0

就像一個魅力!謝謝! – Buendiadas

0

請做如下:

//Adding Smtp information for sending mail through smtp instead of php mail function on local server/live server 

'EmailTransport' => [ 
    'default' => [ 
     'className' => 'Smtp', 
     'host' => 'smtp.1and1.com', 
     'port' =>'587' , 
     'timeout' => 30, 
     'username' => '[email protected]', 
     'password' => '******', 
     'client' => null, 
     'tls' => null, 
    ], 
], 

如果需要,您也可以啓用TLS來'tls' => true

0

在我的情況只是在className中的問題。

使用Gmail或office365服務器應該是這樣:

'EmailTransport' => [ 
     'default' => [ 
      'className' => 'Mail', 
      // The following keys are used in SMTP transports 
      'host' => 'smtp.office365.com', 
      'port' => 587, 
      'timeout' => 30, 
      'username' => '[email protected]', 
      'password' => 'myPassword', 
      'client' => null, 
      'tls' => true, 
      'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null), 
     ], 
    ], 
相關問題