Skip to content

How to send message to another recipient #233

@bobrov-site

Description

@bobrov-site

I have nuxt config file

mail: {
    message: {
      to: process.env.NUXT_ADMIN_MAIL_USER,
    },
    smtp: {
      host: 'smtp.mail.ru',
      port: 465,
      secure: true,
      auth: {
        user: process.env.NUXT_ADMIN_MAIL_USER,
        pass: process.env.NUXT_ADMIN_MAIL_PASSWORD,
      },
    }
  }

But, i want to send message to another recipient, not admin in nuxt config file. How can i do it? I have below my example code for sending. Can you please provide best practicies?

const  { $mail } = useNuxtApp();
    const from = useRuntimeConfig().public.adminMailUser
    console.log($mail, 'mail')
    try {
        await $mail.send({
            from: from,
            subject: subject,
            text: text,
            message: {
                to: to
            }
        })
    }
    catch (e) {
        return {
            error: e.message
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions