A
A
Artyom2020-03-01 15:43:57
Node.js
Artyom, 2020-03-01 15:43:57

How to implement sending email in nuxtjs?

Good afternoon, dear developers. Can you please tell me how to properly send a message from the form?
I am using nuxtjs , for the sendpulse smtp server
This service has an official plugin .
I tried to use the serverMiddleware from the official example , and in the component where the form is located send to a custom route:

methods: {
    onSubmit() {
      var email = {
        html: "<p>Your email content goes here</p>",
        text: this.text,
        subject: "Testing SendPulse API",
        from: {
          name: "Your Sender Name",
          email: "[email protected]"
        },
        to: [
          {
            name: this.name,
            email: this.email
          }
        ]
      };
      console.log(email);
      var answerGetter = function answerGetter(data) {
        console.log(data);
      };
      this.$axios.$post("/api/email", email);
    }
  },

And already in this middleware ~/api/sender.js it's easy to understand that it works
export default (req, res, next) => {
  console.log('works!')
  next()
}

In the server console I get this message, but how logical it is, at the front it swears at a non-existent route:
5e5badb97ca3c614637488.png
Tell me, maybe I'm digging in the wrong direction at all?)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mixonic, 2021-10-07
@Mixonic

i liked it https://github.com/dword-design/nuxt-mail

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question