dword-design/nuxt-mail

400 Bad request /mail/send

Closed this issue · 1 comments

v3nt commented

Trying to send an email from a form in our nuxt app.

Installed as requested and trying to test it locally at the moment.

error

Request URL: http://localhost:3000/mail/send
Request Method: POST
Status Code: 400 Bad Request
Remote Address: 127.0.0.1:3000
Referrer Policy: strict-origin-when-cross-origin

nuxt.config

modules: [
   '@nuxtjs/style-resources',
   'cookie-universal-nuxt',
   '@nuxtjs/axios',
   [
     'nuxt-mail',
     {
       message: {
         to: 'dan@test.net',
       },
       smtp: {
         host: 'localhost',
         port: 587,
       },
     },
   ],
 ],

in default.vue

Using Composition API & typescript.

    const { $axios } = useContext();

    // ...

    async function sendFeedback() {
      await $axios({
        method: 'POST',
        url: `/mail/send`,
        data: {
          to: 'dan@test.net',
          from: 'John Doe',
          subject: 'Incredible',
          text: 'This is an incredible test message',
        },
      });
    }
onMounted(() => {
  sendFeedback();
});

Is any other setup required? Its not clear to me if or what we need to setup for the smtp config.

You will need a valid SMTP server config, may be? Are you hosting an SMTP server locally? Is it up? Try using an external SMTP server as a work-around.