Question

App Platform contact email

Hello,

I’m new to the app platform. Currently I’m working on a NuxtJS static site and everything is working as expected.

The one thing I can’t seem to find in the docs or here in the community is regarding sending an email with a contact form using Nuxt. For examples other services, such Netlify or Firebase, offer functions that allow you to execute some code in the server and do such things. I don’t know if that is possible here in DO App platform.

What I need is quite simple, after the form is validated I want to send an email to a specific address with the fields of the form.

Thanks in advance!!!

Cheers, Rodrigo.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hello,

What I would personally do in such case is to use an SMTP package like nuxt-mail mail for example:

https://www.npmjs.com/package/nuxt-mail

You can install it with:

npm install nuxt-mail

And then you could then specify your SMTP details in your nuxt.config.js file:

export default {
  modules: [
    '@nuxtjs/axios',
    ['nuxt-mail', {
      message: {
        to: 'foo@bar.de',
      },
      smtp: {
        host: "smtp.example.com",
        port: 587,
      },
    }],
  ],
  // or use the top-level option:
  mail: {
    message: {
      to: 'foo@bar.de',
    },
    smtp: {
      host: "smtp.example.com",
      port: 587,
    },
  },
}

The module injects the $mail variable, which we now use to send emails:

// Inside a component
this.$mail.send({
  from: 'John Doe',
  subject: 'Incredible',
  text: 'This is an incredible test message',
})

Note that you would need an SMTP service so that you could set the details correctly in the config file. If you do not have one already, you could use SendGrid for example. They offer a free package which is sufficient for such use cases.

Hope that this helps!

Best,

Bobby