How to send email from multiple message.from () senders

I need to separate the sending of email for two emails for example: “support@gmail.com” and “no-replys@gmail.com
I tried to create a new connection in mail.js and put another configuration in the env. but it didn’t work can someone help me?

ENV:
SMTP_HOST=smtp.umbler.com
MAIL_USERNAME=contact@gmail.rio
MAIL_PASSWORD=MYPASS1
SMTP_PORT=587

SMTP_HOST_WELCOME=smtp.umbler.com
MAIL_USERNAME_WELCOME=welcome@gmail.rio
MAIL_PASSWORD_WELCOME=MYPASS2
SMTP_PORT_WELCOME=587

CONFIG/MAIL.JS:
smtp: {

driver: 'smtp',

name: 'subem.rio',

pool: true,

port: Env.get('SMTP_PORT', 2525),

host: Env.get('SMTP_HOST'),

secure: false,

auth: {

  user: Env.get('MAIL_USERNAME'),

  pass: Env.get('MAIL_PASSWORD')

},

maxConnections: 5,

maxMessages: 100,

rateLimit: 10

},

smtp_welcome: {

driver: 'smtp',

name: 'subem.rio',

pool: true,

port: Env.get('SMTP_HOST_WELCOME', 2525),

host: Env.get('SMTP_PORT_WELCOME'),

secure: false,

auth: {

  user: Env.get('MAIL_USERNAME_WELCOME'),

  pass: Env.get('MAIL_PASSWORD_WELCOME')

},

maxConnections: 5,

maxMessages: 100,

rateLimit: 10

},

await Mail
.connection(‘smtp_welcome’)
.send(‘view’, data, (message) => {
})

https://adonisjs.com/docs/4.1/mail

but that way it doesn’t work, does anyone know how to add two or more email sending accounts?

There’s no need to define your SMTP settings twice.

You should put your email listener somewhere else, like app/Listeners/Messages.js for example and tell your controller when and what to send.

I would do something like this:

'use strict'

const Env = use('Env');
const Mail = use('Mail');
const app_from_title = Env.get('APP_NAME');
const app_from_email = Env.get('APP_FROM_EMAIL');
const Messages = exports = module.exports = {}

const email_addresses = ['user1@example.com', 'user2@example.com', 'user3@example.com'];

Messages.reply = async ({ msg }) => {
  await Mail.send(
    'emails.reply',
    { msg },
    message => {
      message.from(`${app_from_title} <${app_from_email}>`);
      message.subject(`${app_from_title} Inquiry`);
      message.to(email_addresses);
    }
  ).catch(e => {
    console.log('Erro:<', e);
  });
};

Essentially, the message.to()accepts an array so you can put your address there. Hope that helps. Not tested, though.

I’m sorry I think I expressed myself badly, I don’t want to send to several emails I want to send from several emails, in which case I would need to change the message.from ()