Mailvorlagen: pro Vorlage „Kopie an mich" (BCC an Team-Adresse)

- email_templates: neues Feld bcc_team (Checkbox).
- Mailer: ist bcc_team gesetzt, geht die Mail zusätzlich als BCC an
  email_settings.team_email (Kunde sieht die Kopie nicht).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
s4luorth
2026-09-18 07:33:22 +02:00
parent 67e7835214
commit 10776764d7
2 changed files with 5 additions and 2 deletions

View File

@@ -574,6 +574,7 @@ const collections = [
f('body', 'text', { interface: 'input-rich-text-html', note: 'Text (WYSIWYG/HTML). Platzhalter in {{...}}.' }),
f('append_signature', 'boolean', { interface: 'boolean', default: true, note: 'Signatur automatisch anhängen (bei Mails mit eigenem Footer aus).' }),
f('attach_agb', 'boolean', { interface: 'boolean', default: false, note: 'AGB-PDF an diese Mail anhängen.' }),
f('bcc_team', 'boolean', { interface: 'boolean', default: false, note: 'Kopie an mich (Team-Adresse aus email_settings) als BCC senden.' }),
f('enabled', 'boolean', { interface: 'boolean', default: true }),
] },

View File

@@ -97,7 +97,7 @@ export default (register, { services, getSchema, logger }) => {
async function loadTemplate(key, schema) {
const rows = await new ItemsService('email_templates', { schema, accountability: null }).readByQuery({
filter: { key: { _eq: key }, enabled: { _eq: true } },
limit: 1, fields: ['subject', 'body', 'append_signature', 'attach_agb'],
limit: 1, fields: ['subject', 'body', 'append_signature', 'attach_agb', 'bcc_team'],
});
return rows?.[0] || null;
}
@@ -105,7 +105,7 @@ export default (register, { services, getSchema, logger }) => {
async function loadSettings(schema) {
try {
return await new ItemsService('email_settings', { schema, accountability: null })
.readSingleton({ fields: ['signature', 'portal_url', 'company_footer', 'agb_file', 'sender_name', 'sender_email'] });
.readSingleton({ fields: ['signature', 'portal_url', 'company_footer', 'agb_file', 'sender_name', 'sender_email', 'team_email'] });
} catch { return {}; }
}
@@ -227,6 +227,8 @@ export default (register, { services, getSchema, logger }) => {
const anhang = await agbAnhang(schema, settings);
if (anhang) nachricht.attachments = [anhang];
}
// „Kopie an mich" (pro Vorlage): Team-Adresse als BCC (Kunde sieht sie nicht).
if (tpl.bcc_team && settings.team_email) nachricht.bcc = String(settings.team_email).trim();
await new MailService({ schema, accountability: null }).send(nachricht);
logger.info(`[skrift-mailer] „${key}" an ${order.customer_email} (${order.order_number}).`);
}