import type { Mail } from '../types.ts' import { renderTemplate } from './template.tsx' import { transporter } from './transporter.ts' export async function send(mail: Mail) { const { html, text } = await renderTemplate(mail.body) return (await transporter()).sendMail({ from: mail.from.toString(), to: mail.to.map((contact) => contact.toString()), cc: mail.options.cc.map((cc) => cc.toString()), bcc: mail.options.cci.map((cci) => cci.toString()), subject: mail.subject, text, html, attachments: [ { cid: 'cohabit_logo.svg', path: 'https://cohabit.fr/images/logo.svg', filename: 'cohabit_logo.svg', }, ...mail.options.attachments.map((path) => ({ path })), ], }) }