Fix mails and validate succesful deletion of backend vue instance.
This commit is contained in:
parent
00e7d647d3
commit
41ae5da98c
|
|
@ -147,10 +147,8 @@ export default defineNuxtConfig({
|
|||
mail: {
|
||||
host: '',
|
||||
port: '',
|
||||
proxy: '',
|
||||
user: '',
|
||||
passwd: '',
|
||||
dkim: '',
|
||||
}
|
||||
},
|
||||
security: {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export default function(content: VirtualNode[])
|
|||
]),
|
||||
dom('div', { style: 'padding: 1rem;' }, content)
|
||||
]),
|
||||
dom('div', { style: 'margin-left: auto; margin-right: auto; width: 75%; font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; font-size: 1rem; line-height: 1.5rem; color: #171717;' }, [
|
||||
dom('div', { style: 'background-color:#171717;' }, [
|
||||
dom('p', { style: 'padding-top: 1rem; padding-bottom: 1rem; text-align: center; font-size: 0.75rem; line-height: 1rem; color: #fff;', text: 'Copyright Peaceultime / d[any] - 2024 / 2025' })
|
||||
])]
|
||||
}
|
||||
|
|
@ -1,24 +1,18 @@
|
|||
import nodemailer from 'nodemailer';
|
||||
import { createSSRApp, h } from 'vue';
|
||||
import { renderToString } from 'vue/server-renderer';
|
||||
|
||||
import base from '../components/mail/base';
|
||||
import registration from '../components/mail/registration';
|
||||
import reset_password from '../components/mail/reset-password';
|
||||
|
||||
/* import base from '../components/mail/base.vue';
|
||||
import Registration from '../components/mail/registration.vue';
|
||||
import ResetPassword from '../components/mail/reset-password.vue'; */
|
||||
|
||||
const config = useRuntimeConfig();
|
||||
const [domain, selector, dkim] = config.mail.dkim.split(":");
|
||||
|
||||
export const templates: Record<string, { component: (data: any) => string[], subject: string }> = {
|
||||
"registration": { component: registration, subject: 'Bienvenue sur d[any] 😎' },
|
||||
"registration": { component: registration, subject: 'Bienvenue sur d[any]' },
|
||||
"reset-password": { component: reset_password, subject: 'Réinitialisation de votre mot de passe' },
|
||||
};
|
||||
|
||||
import type Mail from 'nodemailer/lib/mailer';
|
||||
import type SMTPPool from 'nodemailer/lib/smtp-pool';
|
||||
interface MailPayload
|
||||
{
|
||||
to: string[];
|
||||
|
|
@ -27,23 +21,15 @@ interface MailPayload
|
|||
}
|
||||
|
||||
const transport = nodemailer.createTransport({
|
||||
//@ts-ignore
|
||||
pool: true,
|
||||
host: config.mail.host,
|
||||
port: config.mail.port,
|
||||
secure: config.mail.port === "465",
|
||||
port: config.mail.port as unknown as number,
|
||||
secure: config.mail.port == "465",
|
||||
auth: {
|
||||
user: config.mail.user,
|
||||
pass: config.mail.passwd,
|
||||
},
|
||||
tls: { rejectUnauthorized: false },
|
||||
dkim: {
|
||||
domainName: domain,
|
||||
keySelector: selector,
|
||||
privateKey: dkim,
|
||||
},
|
||||
proxy: config.mail.proxy,
|
||||
});
|
||||
} as SMTPPool.Options);
|
||||
|
||||
if(process.env.NODE_ENV === 'production')
|
||||
{
|
||||
|
|
@ -79,25 +65,19 @@ export default defineTask({
|
|||
{
|
||||
throw new Error(`Modèle de mail ${mailPayload.template} inconnu`);
|
||||
}
|
||||
|
||||
console.log(`<html><body>${base(template.component(mailPayload.data))}</body></html>`);
|
||||
|
||||
console.time('Generating HTML');
|
||||
const mail: Mail.Options = {
|
||||
from: 'd[any] - Ne pas répondre <no-reply@peaceultime.com>',
|
||||
from: `d[any] - Ne pas répondre <${config.mail.user}>`,
|
||||
to: mailPayload.to,
|
||||
html: `<html><body>${base(template.component(mailPayload.data))}</body></html>`,
|
||||
subject: template.subject,
|
||||
textEncoding: 'quoted-printable',
|
||||
};
|
||||
console.timeEnd('Generating HTML');
|
||||
|
||||
if(mail.html === '')
|
||||
return { result: false, error: new Error("Invalid content") };
|
||||
|
||||
console.time('Sending Mail');
|
||||
const status = await transport.sendMail(mail);
|
||||
console.timeEnd('Sending Mail');
|
||||
|
||||
if(status.rejected.length > 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue