2016-02-29 66 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');即可。
    相关问题