Cannot resolve "Adonis/Addons/Mail" #1596
-
I got an error when I try to run this code from my custom command (Debug.ts)
import { BaseCommand } from '@adonisjs/ace'
import Mail from '@ioc:Adonis/Addons/Mail'
export default class Debug extends BaseCommand {
public static commandName = 'debug'
public static description = 'Run experimental code'
public async handle () {
const { url } = await Mail.preview((message) => {
message
.to('[email protected]')
.from('[email protected]')
.subject('Welcome Onboard!')
.htmlView('emails/welcome')
})
console.log(`Preview url: ${url}`)
}
}
|
Beta Was this translation helpful? Give feedback.
Answered by
RomainLanz
Sep 14, 2020
Replies: 2 comments 1 reply
-
Hey @prab-it! 👋 You need to change a setting in your command so Ace knows that he need to load the application. public static settings = {
loadApp: true,
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
prab-it
-
Similarly, in Adonis 6 you must do the following: static options: CommandOptions = {
startApp: true,
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @prab-it! 👋
You need to change a setting in your command so Ace knows that he need to load the application.
The following code should be added directly inside your command.