dword-design / nuxt-mail

Adds email sending capability to a Nuxt.js app. Adds a server route, an injected variable, and uses nodemailer to send emails.
Other
239 stars 18 forks source link

400 Bad request /mail/send #124

Closed v3nt closed 1 year ago

v3nt commented 2 years ago

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.

nav064 commented 2 years ago

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.