0
我在AWS SES中成功创建了我的SMTP凭据。如何配置CakePHP 3.x以使用Amazon SES SMTP发送电子邮件?
我已经解除了我的限制。
我已经使用command line来测试我的凭证是否正常。
他们是。
我正在使用CakePHP 3.2,但仍无法发送我的电子邮件。
我使用的地区是美国西俄勒冈州。主机是email-smtp.us-west-2.amazonaws.com
我在AWS SES中成功创建了我的SMTP凭据。如何配置CakePHP 3.x以使用Amazon SES SMTP发送电子邮件?
我已经解除了我的限制。
我已经使用command line来测试我的凭证是否正常。
他们是。
我正在使用CakePHP 3.2,但仍无法发送我的电子邮件。
我使用的地区是美国西俄勒冈州。主机是email-smtp.us-west-2.amazonaws.com
echo -n "YOUR SMTP USERNAME" | base64
=
YOUR SMTP PASSWORD
<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
打开你的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!!
],
Email
在app.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');
即可。