mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 00:03:23 +00:00
Add defaultFromName config option and bump to v0.0.7
- Add defaultFromName to MailingPluginConfig interface - Update MailingService to format from field with name when available - Add getDefaultFrom() helper method for consistent formatting - Format as "Name" <email@domain.com> when both name and email are provided - Bump version to 0.0.7 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -48,6 +48,12 @@ export class MailingService implements IMailingService {
|
||||
}
|
||||
}
|
||||
|
||||
private getDefaultFrom(): string {
|
||||
const fromEmail = this.config.defaultFrom
|
||||
const fromName = this.config.defaultFromName
|
||||
return fromName && fromEmail ? `"${fromName}" <${fromEmail}>` : fromEmail || ''
|
||||
}
|
||||
|
||||
private registerHandlebarsHelpers(): void {
|
||||
Handlebars.registerHelper('formatDate', (date: Date, format?: string) => {
|
||||
if (!date) return ''
|
||||
@@ -128,7 +134,7 @@ export class MailingService implements IMailingService {
|
||||
to: Array.isArray(options.to) ? options.to : [options.to],
|
||||
cc: options.cc ? (Array.isArray(options.cc) ? options.cc : [options.cc]) : undefined,
|
||||
bcc: options.bcc ? (Array.isArray(options.bcc) ? options.bcc : [options.bcc]) : undefined,
|
||||
from: options.from || this.config.defaultFrom,
|
||||
from: options.from || this.getDefaultFrom(),
|
||||
replyTo: options.replyTo,
|
||||
subject: subject || options.subject,
|
||||
html,
|
||||
@@ -245,7 +251,7 @@ export class MailingService implements IMailingService {
|
||||
}) as QueuedEmail
|
||||
|
||||
let emailObject: EmailObject = {
|
||||
from: email.from || this.config.defaultFrom,
|
||||
from: email.from || this.getDefaultFrom(),
|
||||
to: email.to,
|
||||
cc: email.cc || undefined,
|
||||
bcc: email.bcc || undefined,
|
||||
@@ -262,7 +268,7 @@ export class MailingService implements IMailingService {
|
||||
}
|
||||
|
||||
const mailOptions = {
|
||||
from: emailObject.from || this.config.defaultFrom,
|
||||
from: emailObject.from,
|
||||
to: emailObject.to,
|
||||
cc: emailObject.cc || undefined,
|
||||
bcc: emailObject.bcc || undefined,
|
||||
|
||||
Reference in New Issue
Block a user