Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

342
Views
I am new to Strapi version 4, I want to confirm my email using the following code

'use strict';

/**
 * A set of functions called "actions" for `email`
 */

module.exports = {
   async index(ctx, next){
    const body = ctx.request.body
    const sendTo = body.email
    const username=body.username
   
    //strapi.log.debug(`Trying to send an email to ${sendTo}`)
    try {
      const emailOptions = {
        to: sendTo,
        subject: `Welcome ${username}`,
        html: `<h1>Welcome ${username}!</h1>
        <p>Thank you for registering!</p>

        <p>You have to confirm your email address. Please click on the link below.</p>
        <p><%= URL %>?confirmation=<%= CODE %></p>
        </p>`,
      }
      await strapi.plugins['email'].services.email.send(emailOptions)
      strapi.log.debug(`Email sent to ${sendTo}`)
      ctx.send({ message: 'Email sent' })
    } catch (err) {
      strapi.log.error(`Error sending email to ${sendTo}`, err)
      ctx.send({ error: 'Error sending email' })
    }
  }
};

I donot know from where this URL AND CODE I will get so that user confirmation changed from false to true at the backend and he will be able to login

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!