Never commit API keys to version control. Use environment variables in production.
3. Send Your First Email
Client-Side (Composable)
Use the useLettermint composable in Vue components:
Code
<script setup lang="ts">const { send, sending, error } = useLettermint()async function sendWelcomeEmail() { await send({ from: 'John Doe <john@yourdomain.com>', to: 'recipient@example.com', subject: 'Hello from Lettermint', text: 'This is a test email sent using the Lettermint Nuxt module.' })}</script><template> <button @click="sendWelcomeEmail" :disabled="sending"> {{ sending ? 'Sending...' : 'Send Email' }} </button> <p v-if="error">{{ error }}</p></template>
Server-Side (API Routes)
Send emails from Nitro server routes:
server/api/send-welcome.post.ts
import { sendEmail } from '#imports'export default defineEventHandler(async () => { return await sendEmail({ from: 'John Doe <john@yourdomain.com>', to: 'recipient@example.com', subject: 'Welcome to our platform', html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>', tags: ['welcome'] })})
Fluent API
Build emails with a chainable API:
Code
const lettermint = useLettermint()await lettermint.email .from('John Doe <john@yourdomain.com>') .to('recipient@example.com') .subject('Hello from Lettermint') .html('<h1>Hello!</h1>') .tag('welcome') .send()
4. Email Features
HTML and Text Content
Code
await send({ from: 'John Doe <john@yourdomain.com>', to: 'recipient@example.com', subject: 'Your account is ready!', html: '<h1>Welcome!</h1><p>Thanks for signing up.</p>', text: 'Welcome! Thanks for signing up.'})
Multiple Recipients
Code
await send({ from: 'John Doe <john@yourdomain.com>', to: ['user1@example.com', 'user2@example.com'], cc: 'manager@yourdomain.com', bcc: 'archive@yourdomain.com', subject: 'Monthly Newsletter', html: '<h1>This Month\'s Updates</h1>'})
Reply-To and Custom Headers
Code
await send({ from: 'support@yourdomain.com', to: 'customer@example.com', replyTo: 'help@yourdomain.com', subject: 'Support Ticket #12345', headers: { 'X-Priority': '1', 'X-Ticket-ID': '12345' }, html: '<p>Your support ticket has been updated.</p>'})
Metadata
Attach data for tracking and webhook payloads:
Code
await send({ from: 'notifications@yourdomain.com', to: 'user@example.com', subject: 'Order Confirmation', metadata: { orderId: 'ORD-12345', customerId: 'CUST-678' }, html: '<p>Your order has been confirmed.</p>'})
Metadata is included in webhook payloads but not sent to recipients.
Tags
Categorize emails for filtering and analytics:
One tag per message. The object API uses tags array, the fluent API uses .tag() method.
See Tags documentation for more details.
Attachments
5. Custom Endpoint
By default, the module creates an endpoint at /api/lettermint/send. Disable it for custom implementations: