1

I just started to use the Adonisjs framework and I try to send an fake email over Mailtrap. The problem is I run always into the Error connect ECONNREFUSED 52.202.164.124:2525.

Env:

MAIL_CONNECTION=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_USERNAME=ebe8f4522c4fcc
MAIL_PASSWORD=0bb7b98785dab1

config/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
  },

Controller:

await Mail.send('authentication.emails.confirm_email', user.toJSON(), message => {
            message.to(user.email)
            .from('hello@adonisjs.com')
            .subject('Please confirm your email address')
        })

Adonisjs Error, Code 500

Maybe somebody can help me :)

2 Answers2

0

I changed the port to 25 and it works now. I still don't know the reason why I couldn't get a connection bevore. It may be the firewall.

0

change the value to MAIL_PORT=25

  • 1
    Thank you for this code snippet, which might provide some limited, immediate help. A [proper explanation](https://meta.stackexchange.com/q/114762/349538) would greatly improve its long-term value by showing why this is a good solution to the problem and would make it more useful to future readers with other, similar questions. Please [edit] your answer to add some explanation, including the assumptions you’ve made. – Dwhitz Jun 03 '19 at 14:19