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');
即可。