Add logo attachment to email and update image source in Base component
This commit is contained in:
parent
24c9754dae
commit
df9313b3b4
3 changed files with 35 additions and 7 deletions
|
|
@ -45,10 +45,12 @@ const Base = ({
|
|||
referrerPolicy="no-referrer"
|
||||
width={230.5}
|
||||
height={44.25}
|
||||
src={
|
||||
"https://lh3.google.com/u/0/d/1nEurjVWPiz0F8QRLhKcT4ZSujeFRChBs" //TEMP FIX
|
||||
//getMediaUrl("/Infoalloggi.png")
|
||||
}
|
||||
// src={
|
||||
// process.env.NEXT_PUBLIC_BASE_URL?.includes("localhost")
|
||||
// ? "https://lh3.google.com/u/0/d/1nEurjVWPiz0F8QRLhKcT4ZSujeFRChBs"
|
||||
// : process.env.NEXT_PUBLIC_BASE_URL + "/Infoalloggi.png"
|
||||
// }
|
||||
src="cid:logo"
|
||||
alt="Infoalloggi.it"
|
||||
className="mx-auto my-2 scale-80"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,26 @@
|
|||
import { createTRPCRouter, protectedApiProcedure } from "~/server/api/trpc";
|
||||
import {
|
||||
createTRPCRouter,
|
||||
protectedApiProcedure,
|
||||
publicProcedure,
|
||||
} from "~/server/api/trpc";
|
||||
import { genMail, NewMail } from "~/server/services/mailer";
|
||||
|
||||
export const testRouter = createTRPCRouter({
|
||||
testApi: protectedApiProcedure.query(async () => {
|
||||
return "Hello World!";
|
||||
}),
|
||||
testMail: publicProcedure.query(async ({ ctx }) => {
|
||||
const mail = await NewMail({
|
||||
to: "m.pedone98@gmail.com",
|
||||
subject: "Test Email",
|
||||
|
||||
mailType: "pwResetLink",
|
||||
props: {
|
||||
resetlink: "https://example.com/reset-password",
|
||||
},
|
||||
});
|
||||
return mail;
|
||||
}),
|
||||
|
||||
/*
|
||||
PROTECTED API CALL EXAMPLE
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import type { Recesso_NewMail } from "emails/recesso";
|
|||
import Recesso from "emails/recesso";
|
||||
import type { RegistrazioneAvvenuta_NewMail } from "emails/registrazione-avvenuta";
|
||||
import RegistrazioneAvvenuta from "emails/registrazione-avvenuta";
|
||||
import { createTransport } from "nodemailer";
|
||||
import { createTransport, type TransportOptions } from "nodemailer";
|
||||
import { htmlToText } from "nodemailer-html-to-text";
|
||||
import { env } from "~/env.mjs";
|
||||
import type { JSX } from "react";
|
||||
|
|
@ -36,6 +36,7 @@ import type { Generic_NewMail } from "emails/gereric-email";
|
|||
import Generic from "emails/gereric-email";
|
||||
import { GetFlagValueHandler } from "~/server/controllers/flags.controller";
|
||||
import { db } from "~/server/db";
|
||||
import type { Options } from "nodemailer/lib/mailer";
|
||||
|
||||
type MailerProps = {
|
||||
to: string;
|
||||
|
|
@ -60,11 +61,19 @@ const mailer = async ({ to, subject, html }: MailerProps) => {
|
|||
});
|
||||
smtpTransport.use("compile", htmlToText());
|
||||
|
||||
const message = {
|
||||
const message: Options = {
|
||||
from: `"InfoAlloggi" <${env.ARUBA_USER}>`,
|
||||
to: to,
|
||||
subject: subject,
|
||||
html: html,
|
||||
attachments: [
|
||||
{
|
||||
filename: "Infoalloggi.png",
|
||||
path: "./public/Infoalloggi.png",
|
||||
contentType: "image/png",
|
||||
cid: "logo",
|
||||
},
|
||||
],
|
||||
};
|
||||
smtpTransport.sendMail(message, (err, info) => {
|
||||
if (err) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue