Make mailer transport config optional, use Payload config fallback

- Updated MailingService to check for Payload's email transporter when plugin transport is not configured
- Enhanced error message to indicate transport is required in either plugin or Payload config
- Bump version to 0.0.5

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-13 15:56:25 +02:00
parent d672ebace2
commit a32d5688c4
2 changed files with 6 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@xtr-dev/payload-mailing",
"version": "0.0.4",
"version": "0.0.5",
"description": "Template-based email system with scheduling and job processing for PayloadCMS",
"type": "module",
"main": "dist/index.js",

View File

@@ -38,10 +38,13 @@ export class MailingService implements IMailingService {
if ('sendMail' in this.config.transport) {
this.transporter = this.config.transport
} else {
this.transporter = nodemailer.createTransport(this.config.transport as MailingTransportConfig)
this.transporter = nodemailer.createTransporter(this.config.transport as MailingTransportConfig)
}
} else if (this.payload.email) {
// Use Payload's configured mailer
this.transporter = this.payload.email
} else {
throw new Error('Email transport configuration is required')
throw new Error('Email transport configuration is required either in plugin config or Payload config')
}
}