nuxt-mailer
Advanced tools
Comparing version 0.5.0 to 0.6.0
{ | ||
"name": "nuxt-mailer", | ||
"configKey": "mailer", | ||
"version": "0.5.0" | ||
"version": "0.6.0" | ||
} |
{ | ||
"name": "nuxt-mailer", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -8,4 +8,74 @@ # Nuxt Module | ||
Install | ||
```bash | ||
npm install nuxt-mailer | ||
``` | ||
``` | ||
Add nuxt-mailer to nuxt.config modules array | ||
```js | ||
export default defineNuxtConfig({ | ||
modules: ['nuxt-mailer'] | ||
}) | ||
``` | ||
Example usage: | ||
> server/app/email/emailSender.ts | ||
```ts | ||
import { useMailer } from '#mailer' | ||
import { EmailTemplate } from './types/emailTypes' | ||
export async function sendEmail(template: EmailTemplate , to: string, from: string, subject: string) { | ||
const mailer = useMailer() | ||
const username = process.env.MAIL_USERNAME as string | ||
const password = process.env.MAIL_PASSWORD as string | ||
const gmailTranport = mailer.customTranporter({ | ||
service: 'gmail', | ||
auth: { | ||
user: username, | ||
pass: password | ||
} | ||
}) | ||
console.log('username: ', username) | ||
console.log('password: ', password) | ||
console.log('from: ',from) | ||
console.log('to: ',to) | ||
console.log('html: ', template.html) | ||
console.log('text: ', template.text) | ||
console.log('subject: ', subject) | ||
await mailer.sendMail({ | ||
requestId: 'test-key', | ||
options: { | ||
from: from, | ||
to: to, | ||
subject: subject, | ||
text: template.text, | ||
html: template.html | ||
}, | ||
transporter: gmailTranport | ||
}) | ||
} | ||
``` | ||
> server/app/email/verifyEmail.ts | ||
```ts | ||
import verifyEmailTemplate from './templates/verifyEmailTemplate' | ||
import { sendEmail } from './emailSender' | ||
export default async function sendVerificationEmail(email: string) { | ||
const template = verifyEmailTemplate('coolbeans', 'support@fullstackjack.dev', 'Avantage Support', 'Avantage') | ||
sendEmail(template, email, 'jack@fullstackjack.dev', 'Avantage email verification') | ||
} | ||
``` | ||
My wife is giving me that "you better get off your laptop and celebrate Christmas" stare | ||
I'll post more examples after the holidays. . . | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7679
81