Package Exports
- nuxt-mail
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nuxt-mail) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
nuxt-mail
Adds email sending capability to a Nuxt.js app. Adds a server route, an injected variable, and uses nodemailer to send emails. Works for universal mode.
Install
# NPM
$ npm install nuxt-mail
# Yarn
$ yarn add nuxt-mailUsage
Add the module to your nuxt.config.js. 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', {
smtp: {
host: "smtp.example.com",
port: 587,
},
}],
],
// or use the top-level option:
mail: {
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 note that the module only works for universal mode and not for nuxt generate, because we need the server route (see the Nuxt.js documentation for details about the mode).
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',
to: 'johndoe@gmail.com',
})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',
to: 'johndoe@gmail.com',
})Note that the data are passed to nodemailer. Refer to the documentation for available config options.
License
Unless stated otherwise all works are:
Copyright © Sebastian Landwehr info@dword-design.de
and licensed under: