Package Exports
- @tenfoldstudio/mailjet-adapter
Readme
Mailjet Adapter for Payload CMS
A Payload CMS email adapter for Mailjet using the official node-mailjet library.
Installation
npm install @tenfoldstudio/mailjet-adapter node-mailjetImportant: You must install node-mailjet as a dependency in your project. This package is marked as an external dependency to avoid bundling issues.
Usage
Basic Setup
import { buildConfig } from 'payload/config'
import { mailjetAdapter } from '@tenfoldstudio/mailjet-adapter'
export default buildConfig({
// ... other config
email: mailjetAdapter({
apiKey: process.env.MAILJET_API_KEY!,
apiSecret: process.env.MAILJET_API_SECRET!,
defaultFromAddress: 'noreply@basc.aero',
defaultFromName: 'BASC',
}),
})Environment Variables
Add these to your .env file:
MAILJET_API_KEY=your_mailjet_api_key
MAILJET_API_SECRET=your_mailjet_api_secretSending Emails
Basic Email
import { sendEmail } from '@tenfoldstudio/mailjet-adapter';
await sendEmail({
to: 'user@example.com',
subject: 'Welcome!',
html: '<h1>Welcome to our app!</h1>',
text: 'Welcome to our app!',
})Using Mailjet Templates
await sendEmail({
to: 'user@example.com',
subject: 'Welcome!',
templateId: 123456, // Your Mailjet template ID
data: {
name: 'John Doe',
company: 'Acme Corp',
},
})With Attachments
`