Passing variables to mail template breaks mail

#1

Hi there, I’m trying to pass variable data to a mail template from my adonis controller method.

below is the way I’m currently handling this

const body = request.all() 
const email = body.email
const talent = await Talent.all()

await Mail.send('emails.interviewInvite', {talent, body}, (message) => {
    message
    .to(email)
    .from(Env.get('MAIL_FROM'))
    .subject("You're invited for an Interview!")
    .noReply('no-reply@example.com')
})

Unfortunately the above code breaks the application and give this error

message.to(...).from(...).subject(...).noReply is not a function
0 Likes

#2

Hi @iamtunde

I can’t see a method called noReply in documentation. You may check it out here

Do you mean to use replyTo?

1 Like

#3

Thank @ozziest for your response, after going through the docs myself, I had realised what the issue was. Just has you’ve pointed it’s the noReply method in the code.

Thanks again.

1 Like