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: {
|
mail: {
|
||||||
host: '',
|
host: '',
|
||||||
port: '',
|
port: '',
|
||||||
proxy: '',
|
|
||||||
user: '',
|
user: '',
|
||||||
passwd: '',
|
passwd: '',
|
||||||
dkim: '',
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
security: {
|
security: {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export default function(content: VirtualNode[])
|
||||||
]),
|
]),
|
||||||
dom('div', { style: 'padding: 1rem;' }, content)
|
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' })
|
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 nodemailer from 'nodemailer';
|
||||||
import { createSSRApp, h } from 'vue';
|
|
||||||
import { renderToString } from 'vue/server-renderer';
|
|
||||||
|
|
||||||
import base from '../components/mail/base';
|
import base from '../components/mail/base';
|
||||||
import registration from '../components/mail/registration';
|
import registration from '../components/mail/registration';
|
||||||
import reset_password from '../components/mail/reset-password';
|
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 config = useRuntimeConfig();
|
||||||
const [domain, selector, dkim] = config.mail.dkim.split(":");
|
|
||||||
|
|
||||||
export const templates: Record<string, { component: (data: any) => string[], subject: string }> = {
|
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' },
|
"reset-password": { component: reset_password, subject: 'Réinitialisation de votre mot de passe' },
|
||||||
};
|
};
|
||||||
|
|
||||||
import type Mail from 'nodemailer/lib/mailer';
|
import type Mail from 'nodemailer/lib/mailer';
|
||||||
|
import type SMTPPool from 'nodemailer/lib/smtp-pool';
|
||||||
interface MailPayload
|
interface MailPayload
|
||||||
{
|
{
|
||||||
to: string[];
|
to: string[];
|
||||||
|
|
@ -27,23 +21,15 @@ interface MailPayload
|
||||||
}
|
}
|
||||||
|
|
||||||
const transport = nodemailer.createTransport({
|
const transport = nodemailer.createTransport({
|
||||||
//@ts-ignore
|
|
||||||
pool: true,
|
pool: true,
|
||||||
host: config.mail.host,
|
host: config.mail.host,
|
||||||
port: config.mail.port,
|
port: config.mail.port as unknown as number,
|
||||||
secure: config.mail.port === "465",
|
secure: config.mail.port == "465",
|
||||||
auth: {
|
auth: {
|
||||||
user: config.mail.user,
|
user: config.mail.user,
|
||||||
pass: config.mail.passwd,
|
pass: config.mail.passwd,
|
||||||
},
|
},
|
||||||
tls: { rejectUnauthorized: false },
|
} as SMTPPool.Options);
|
||||||
dkim: {
|
|
||||||
domainName: domain,
|
|
||||||
keySelector: selector,
|
|
||||||
privateKey: dkim,
|
|
||||||
},
|
|
||||||
proxy: config.mail.proxy,
|
|
||||||
});
|
|
||||||
|
|
||||||
if(process.env.NODE_ENV === 'production')
|
if(process.env.NODE_ENV === 'production')
|
||||||
{
|
{
|
||||||
|
|
@ -80,24 +66,18 @@ export default defineTask({
|
||||||
throw new Error(`Modèle de mail ${mailPayload.template} inconnu`);
|
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 = {
|
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,
|
to: mailPayload.to,
|
||||||
html: `<html><body>${base(template.component(mailPayload.data))}</body></html>`,
|
html: `<html><body>${base(template.component(mailPayload.data))}</body></html>`,
|
||||||
subject: template.subject,
|
subject: template.subject,
|
||||||
textEncoding: 'quoted-printable',
|
textEncoding: 'quoted-printable',
|
||||||
};
|
};
|
||||||
console.timeEnd('Generating HTML');
|
|
||||||
|
|
||||||
if(mail.html === '')
|
if(mail.html === '')
|
||||||
return { result: false, error: new Error("Invalid content") };
|
return { result: false, error: new Error("Invalid content") };
|
||||||
|
|
||||||
console.time('Sending Mail');
|
|
||||||
const status = await transport.sendMail(mail);
|
const status = await transport.sendMail(mail);
|
||||||
console.timeEnd('Sending Mail');
|
|
||||||
|
|
||||||
if(status.rejected.length > 0)
|
if(status.rejected.length > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue