[英]How to configure CakePHP 3.x to use Amazon SES SMTP to send out emails?
I have successfully created my SMTP credentials in AWS SES. 我已经在AWS SES中成功创建了SMTP凭证。
I have lifted my restrictions. 我解除了限制。
I have used the command line to test if my credentials are okay. 我已经使用命令行来测试我的凭据是否还可以。
They are. 他们是。
I am using CakePHP 3.2 but still unable to send out my emails. 我正在使用CakePHP 3.2,但仍然无法发送电子邮件。
The region I use is US West Oregon. 我使用的地区是美国俄勒冈州西部。 The host is
email-smtp.us-west-2.amazonaws.com
主持人是
email-smtp.us-west-2.amazonaws.com
echo -n "YOUR SMTP USERNAME" | base64
echo -n "YOUR SMTP USERNAME" | base64
echo -n "YOUR SMTP USERNAME" | base64
=
=
结尾 YOUR SMTP PASSWORD
YOUR SMTP PASSWORD
重复步骤1和2 <whatever>
as you deem fit. <whatever>
。 Like this: 像这样:
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:<yourverifiedemail@example.com>
AFTER 250 Ok
RCPT TO:<yourverifiedemail@example.com>
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.
.
Type openssl s_client -crlf -quiet -connect email-smtp.us-west-2.amazonaws.com:465
into your terminal 在终端中输入
openssl s_client -crlf -quiet -connect email-smtp.us-west-2.amazonaws.com:465
Follow the instructions in the text file. 请按照文本文件中的说明进行操作。
Once ascertained that credentials are good, now configure your cakephp 3.x 一旦确定凭据是好的,现在配置您的cakephp 3.x
Open up your config/app.php
打开您的
config/app.php
Find EmailTransport
and add a new transport below default 查找
EmailTransport
并在默认值以下添加新的传输
Like this: 像这样:
'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
in app.php
and add a new profile below default app.php
查找Email
并在默认值下方添加新的配置文件 Like this: 像这样:
'Email' => [
'default' => [
'transport' => 'default',
'from' => 'you@localhost',
//'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');
$email = new Email('production');
at the appropriate place that you want.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.