Hi all, I am developing Adonis restful API services ( version 4.0). I am using adonis mail in my code. I have followed doc but I got an error like this : Cannot find module 'Adonis/Src/View'
Webstorm & insomina ( rest client )

config/Mail.js - I am using mailtrap
'use strict'
const Env = use('Env')
module.exports = {
connection: Env.get('MAIL_CONNECTION', 'smtp'),
smtp: {
driver: 'smtp',
pool: true,
port: 2525,
host: 'smtp.mailtrap.io',
secure: false,
auth: {
user: "########",
pass: "########"
},
maxConnections: 5,
maxMessages: 100,
rateLimit: 10
},
sparkpost: {
driver: 'sparkpost',
apiKey: Env.get('SPARKPOST_API_KEY'),
extras: {}
}
}
my Code : in user controller
// Store the information
async store({request, response}) {
let validation = await validate(request.all(), rules)
if (validation.fails()) {
return response.status(400).json({data: 'error', message: validation._errorMessages[0].message, status: false})
}
const userInfo = request.all();
const users = new User();
users.username = userInfo.username;
users.email = userInfo.email;
users.password = userInfo.password;
let checkUser = await dataBase.table('users').where('email', '=', users.email)
if (checkUser.length > 0) {
return response.status(400).json({data: 'insert fail', message: 'email already register', status: false})
}
await users.save();
// sending mail after registration
const data =request.only(['username','email', 'password']);
await Mail.send('emails.welcome', {}, (message) => {
message.from('#####.com')
message.to('####.com')
})
return response.status(201).json({message: 'user created successfull', status: true});
}

Yes emails are stored in view templates, so you need to register the view provider inside the providers array
'@adonisjs/framework/providers/ViewProvider'
Thanks thetutlage Its working fine.
Should be added to docs, imo. Mail requires ViewProvider added or smth. (in mail section)
@outluch PRs are welcomed 馃
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Yes emails are stored in view templates, so you need to register the view provider inside the providers array