All Projects → dword-design → nuxt-mail

dword-design / nuxt-mail

Licence: other
Adds email sending capability to a Nuxt.js app. Adds a server route, an injected variable, and uses nodemailer to send emails.

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to nuxt-mail

nuxt-prune-html
🔌⚡ Nuxt module to prune html before sending it to the browser (it removes elements matching CSS selector(s)), useful for boosting performance showing a different HTML for bots/audits by removing all the scripts with dynamic rendering
Stars: ✭ 69 (+11.29%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
nuxt-stripejs
💳 NuxtJS module for Stripe.js which loads only when required and w/ retry mechanism
Stars: ✭ 17 (-72.58%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
vue-plausible
Plausible Analytics Vue.js Plugin and NuxtJS Module
Stars: ✭ 107 (+72.58%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
nuxt-modules
AX2's Nuxt modules
Stars: ✭ 30 (-51.61%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
applicationinsights-module
Application Insights module for NuxtJS
Stars: ✭ 14 (-77.42%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
nuxt-typo3
TYPO3 Frontend rendered in Vue.js and Nuxt (frontend for EXT:headless)
Stars: ✭ 66 (+6.45%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
supabase
An easy way to integrate Supabase with NuxtJS
Stars: ✭ 39 (-37.1%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
bulk-mail-cli
Do quick, hassle-free email marketing with this small but very powerful tool! 🔥
Stars: ✭ 88 (+41.94%)
Mutual labels:  mail, npm-package, nodemailer
nuxt-jsonld
A Nuxt.js module to manage JSON-LD in Vue component.
Stars: ✭ 198 (+219.35%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
nuxt-quasar
Nuxt module for the Quasar Framework
Stars: ✭ 36 (-41.94%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
nuxt-gsap-module
GSAP module for Nuxt.js
Stars: ✭ 183 (+195.16%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
nuxt-ghost
Easy Ghost content API integration with Nuxt.js.
Stars: ✭ 27 (-56.45%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
cloudinary-module
Integration of Cloudinary to Nuxt.js
Stars: ✭ 129 (+108.06%)
Mutual labels:  nuxtjs, nuxt-module, nuxtjs-module
nuxt-humans-txt
🧑🏻👩🏻 "We are people, not machines" - An initiative to know the creators of a website. Contains the information about humans to the web building - A Nuxt Module to statically integrate and generate a humans.txt author file - Based on the HumansTxt Project.
Stars: ✭ 27 (-56.45%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
Free Email Forwarding
The best free email forwarding for custom domains. Visit our website to get started (SMTP server)
Stars: ✭ 2,024 (+3164.52%)
Mutual labels:  mail, email, nodemailer
nuxt-ts-module
A tiny module to use Typescript within Nuxt.js application.
Stars: ✭ 21 (-66.13%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
global-components
Module to register global components for Nuxt.js
Stars: ✭ 57 (-8.06%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
k-domains
A simple module to manage multiple subdomains with just one project
Stars: ✭ 41 (-33.87%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
lumen-cms
GraphQL API-First CMS based on NodeJS and Vue 2, Nuxt and Vuetify
Stars: ✭ 77 (+24.19%)
Mutual labels:  nuxt, nuxtjs, nuxt-module
nuxt-speedkit
nuxt-speedkit will help you to improve the lighthouse performance score (100/100) of your website.
Stars: ✭ 401 (+546.77%)
Mutual labels:  nuxt, nuxtjs, nuxt-module

nuxt-mail

npm version Linux macOS Windows compatible Build status Coverage status Dependency status Renovate enabled
Open in Gitpod Buy Me a Coffee PayPal Patreon

Adds email sending capability to a Nuxt.js app. Adds a server route, an injected variable, and uses nodemailer to send emails.

Does not work for static sites (via nuxt generate) because the module creates a server route.

Install

# npm
$ npm install nuxt-mail

# Yarn
$ yarn add nuxt-mail

Usage

Add the module to the modules array in your nuxt.config.js. Note to add it to modules instead of buildModules, otherwise the server route will not be generated. We also have to install the @nuxtjs/axios module because it is used internally to call the server route:

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

The smtp options are required and directly passed to nodemailer. Refer to their documentation for available options. Also, you have to pass at least to, cc or bcc via the message config. This has security reasons, this way the client cannot send emails from your SMTP server to arbitrary recipients. You can actually preconfigure the message via the message config, so if you always want to send emails with the same subject or from address, you can configure them here.

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',
})

You can also directly call the generated /mail/send post route:

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

Note that the data are passed to nodemailer. Refer to the documentation for available config options.

Multiple message configs

It is also possible to provide multiple message configurations by changing the message config into an array.

export default {
  modules: [
    '@nuxtjs/axios',
    ['nuxt-mail', {
      message: [
        { name: 'contact', to: '[email protected]' },
        { name: 'support', to: '[email protected]' },
      ],
      ...
    }],
  ],
}

Then you can reference the config like this:

this.$axios.$post('/mail/send', {
  config: 'support',
  from: 'John Doe',
  subject: 'Incredible',
  text: 'This is an incredible test message',
})

Or via index (in which case you do not need the name property):

this.$axios.$post('/mail/send', {
  config: 1, // Resolves to 'support'
  from: 'John Doe',
  subject: 'Incredible',
  text: 'This is an incredible test message',
})

Note about production use

When you use nuxt-mail in production and you configured a reverse proxy that hides your localhost behind a domain, you need to tell @nuxt/axios which base URL you are using. Otherwise nuxt-mail won't find the send route. Refer to @nuxt/axios options on how to do that. The easiest option is to set the API_URL environment variable, or set something else in your nuxt.config.js:

// nuxt.config.js

export default {
  axios: {
    baseURL: process.env.BASE_URL,
  },
}

Also, the module does not work for static sites (via nuxt generate) because the module creates a server route.

Setting up popular email services

Gmail

You have to setup an app-specific password to log into the SMTP server. Then, add the following config to your nuxt-mail config:

export default {
  modules: [
    '@nuxtjs/axios',
    ['nuxt-mail', {
      // ...
      smtp: {
        service: 'gmail',
        auth: {
          user: '[email protected]',
          pass: '<app-specific password>',
        },
      },
    }],
  ],
}

Missing something? Add your service here via a pull request.

Debugging mail errors

If the mail doesn't get sent, you can debug the error using the browser developer tools. If a 400 error is thrown (check out the console output), you can find the error message in the Network tab. For Chrome users, open the Network tab, then find the "send" request. Open it and select the "Response" tab. There it should show the error message. In most cases, it is related to authentication with the SMTP server.

Open questions

"Self signed certificate in certificate chain" error

There is an issue where the above error is thrown. If someone knows a solution for this, it is warmly welcome 😍.

Contribute

Are you missing something or want to contribute? Feel free to file an issue or a pull request! ⚙️

Support

Hey, I am Sebastian Landwehr, a freelance web developer, and I love developing web apps and open source packages. If you want to support me so that I can keep packages up to date and build more helpful tools, you can donate here:

Buy Me a Coffee  If you want to send me a one time donation. The coffee is pretty good 😊.
PayPal  Also for one time donations if you like PayPal.
Patreon  Here you can support me regularly, which is great so I can steadily work on projects.

Thanks a lot for your support! ❤️

See also

  • nuxt-route-meta: Adds Nuxt page data to route meta at build time.
  • nuxt-modernizr: Adds a Modernizr build to your Nuxt.js app.
  • nuxt-mermaid-string: Embed a Mermaid diagram in a Nuxt.js app by providing its diagram string.
  • nuxt-content-git: Additional module for @nuxt/content that replaces or adds createdAt and updatedAt dates based on the git history.
  • nuxt-babel-runtime: Nuxt CLI that supports babel. Inspired by @nuxt/typescript-runtime.

License

MIT License © Sebastian Landwehr

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].