2016-02-29 122 views

回答

3

如何測試如果憑據通過命令行都還好

  1. 打開你的服務器終端輸入echo -n "YOUR SMTP USERNAME" | base64
  2. 複製粘貼輸出的地方。你將需要它。輸出應該與=
  3. 重複步驟1和2結束對YOUR SMTP PASSWORD
  4. 複製以下內容粘貼到一個文本文件,但更換<whatever>,你認爲合適。

像這樣:

AFTER 220 .... PASTE THE LINE BELOW: 
EHLO <example.com> 

AFTER 250 Ok PASTE THE LINE BELOW: 
AUTH LOGIN 

AFTER 334 VXNlcm5hbWU6: 
<YOUR SMTP USERNAME encoded as base64 from step 1> 

AFTER 334 UGFzc3dvcmQ6: 
<YOUR SMTP PASSWORD encoded as base64 from step 3> 

AFTER 235 Authentication successful. 
MAIL FROM:<[email protected]> 

AFTER 250 Ok 
RCPT TO:<[email protected]> 

AFTER 250 Ok 
DATA 

AFTER 354 End data with <CR><LF>.<CR><LF>  
Subject:Hello from Amazon SES! 

This email was sent using the Amazon SES SMTP interface. 
. 
  • 類型openssl s_client -crlf -quiet -connect email-smtp.us-west-2.amazonaws.com:465到您的終端

  • 按照在文本文件中的說明。

  • 一旦確定,憑證都不錯,現在配置您的CakePHP 3.X

    配置蛋糕3.X

    • 打開你的config/app.php

    • 查找EmailTransport並添加低於默認值的新運輸方式

    像這樣:

    '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, 
        ], 
        // START of what you need to add!! 
        'AWS_SES' =>[ 
         'className' => 'Smtp', 
         'host' => 'email-smtp.us-west-2.amazonaws.com', 
         'port' => 587, // this is very important to be 587!! 
         'timeout' => 30, 
         'username' => 'YOUR SMTP USERNAME', 
         'password' => 'YOUR SMTP PASSWORD', 
         'tls' => true, // this is also very important!! 
        ] 
        // END of what you need to add!! 
    ], 
    
    • 現在查找Emailapp.php並添加默認以下新的配置文件

    像這樣:

    'Email' => [ 
        'default' => [ 
         'transport' => 'default', 
         'from' => '[email protected]', 
         //'charset' => 'utf-8', 
         //'headerCharset' => 'utf-8', 
        ], 
    // START of what you need to add! 
        'production' => [ 
         'transport' => 'AWS_SES', 
         //'log' => true, 
        ] 
    // END of what you need to add! 
    ], 
    
    • 這是所有組態!
    • 只需在適當的地方撥打$email = new Email('production');即可。