我刚开始使用 Adonisjs 框架,并尝试通过 Mailtrap 发送假电子邮件。问题是我总是遇到错误连接 ECONNREFUSED 52.202.164.124:2525。
环境:
MAIL_CONNECTION=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_USERNAME=ebe8f4522c4fcc
MAIL_PASSWORD=0bb7b98785dab1
配置/mail.js:
connection: Env.get('MAIL_CONNECTION', 'smtp'),
/*
|--------------------------------------------------------------------------
| SMTP
|--------------------------------------------------------------------------
|
| Here we define configuration for sending emails via SMTP.
|
*/
smtp: {
driver: 'smtp',
pool: true,
port: 2525,
host: Env.get('MAIL_HOST'),
secure: false,
auth: {
user: Env.get('MAIL_USERNAME'),
pass: Env.get('MAIL_PASSWORD')
},
maxConnections: 5,
maxMessages: 100,
rateLimit: 10
},
控制器:
await Mail.send('authentication.emails.confirm_email', user.toJSON(), message => {
message.to(user.email)
.from('hello@adonisjs.com')
.subject('Please confirm your email address')
})
也许有人可以帮助我:)