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

171
Views
Is there a way one can send different emails to different people using nodemailer?

I want to send an email to the user saying

hey u have successfully registered please refer the code below 234234

and an email to the owner saying

user 234234 has registered 
            let transporter = nodemailer.createTransport({
                service: 'gmail',
                port: 587,
                secure: false,
                requireTLS: true,
                auth: {
                    user: MYEMAIL,
                    pass: MYPASSWORD,
                }
            })

            const randomGenerator = Math.floor(100000 + Math.random() * 900000)
        
            let mailOptions = {
                to: [
                            { name: "Receiver Name 1", address: "receiver1@example.com" },
                            { name: "Receiver Name 2", address: "receiver2@example.com" },
                    ], 
                subject: 'You have successfully registered, Please refer the code given below',
                text: `Your code is ${randomGenerator}`
            }
        
            transporter.sendMail(mailOptions, (err, info) => {
                if(err) console.log(err)
                else{
                    console.log('email sent' + info.response)
                }
            })

so far i've tried making an array of subject and text so that the email sends them orderwise, but instead, it sent the same email to the user and owner twice

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Just call .sendMail() more than once and feed it different addressees and different email content each time you call it. One call to .sendMail() has one set of addressees and one piece of email content. So, to send different content, use separate calls to .sendMail() and vary the inputs.

about 4 years ago · Juan Pablo Isaza Report
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!