diff --git a/emails/EmailLayout.tsx b/emails/EmailLayout.tsx index 8d2df1b5..21a23c81 100644 --- a/emails/EmailLayout.tsx +++ b/emails/EmailLayout.tsx @@ -1,15 +1,12 @@ import { Body, - Button, Container, Head, Html, Img, - Link, Preview, Section, Tailwind, - Text, } from "@react-email/components"; import * as React from "react"; import { PropsWithChildren } from "react"; @@ -31,7 +28,7 @@ export const EmailLayout = ({ children, preview }: PropsWithChildren<{ preview?: Logo diff --git a/emails/HelloEmail.tsx b/emails/HelloEmail.tsx new file mode 100644 index 00000000..b08f2cb5 --- /dev/null +++ b/emails/HelloEmail.tsx @@ -0,0 +1,16 @@ +import { Button } from "@react-email/button"; +import { Html } from "@react-email/html"; +import * as React from "react"; + +export default function HelloEmail() { + return ( + + + + ); +} \ No newline at end of file diff --git a/emails/TestEmailSettings.tsx b/emails/TestEmailSettings.tsx index c7bc771b..f191ed02 100644 --- a/emails/TestEmailSettings.tsx +++ b/emails/TestEmailSettings.tsx @@ -3,26 +3,40 @@ import { } from "@react-email/components"; import * as React from "react"; import EmailLayout from "./EmailLayout"; +import {Button} from "@react-email/button"; export const TestEmailSettings = () => { return ( + - Hi, this is a test email for settings and alerts ! + Hi, your email settings are setup ! + + - Soluce Technologies | Portabase - + className="text-base font-light leading-8 text-green-800 " + + > + Best regard, + + Portabase + + ); }; + export default TestEmailSettings; diff --git a/package.json b/package.json index a4b4c60a..95f19081 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "dev": "next dev -p 80", "build": "next build", "start": "next start", - "lint": "next lint" + "lint": "next lint", + "email": "email dev" + }, "dependencies": { "@auth/prisma-adapter": "^2.4.1", diff --git a/src/components/wrappers/Dashboard/Settings/SettingsEmailTab/SettingsEmailTab.tsx b/src/components/wrappers/Dashboard/Settings/SettingsEmailTab/SettingsEmailTab.tsx index d9764ced..81f61c3c 100644 --- a/src/components/wrappers/Dashboard/Settings/SettingsEmailTab/SettingsEmailTab.tsx +++ b/src/components/wrappers/Dashboard/Settings/SettingsEmailTab/SettingsEmailTab.tsx @@ -7,6 +7,7 @@ import {sendEmail} from "@/utils/email-helper"; import TestEmailSettings from "../../../../../../emails/TestEmailSettings"; import {render} from "@react-email/render"; import {toast} from "sonner"; +import HelloEmail from "../../../../../../emails/HelloEmail"; @@ -20,8 +21,8 @@ export const SettingsEmailTab = (props: SettingsEmailTabProps) => { mutationFn: async () => { const email = await sendEmail({ to: props.settings.smtpUser, - subject: "Portabase email test !", - html: await render(TestEmailSettings(), {}) + subject: "Portabase", + html: await render(TestEmailSettings(),{}) }); if(email.response){ toast.success("Test Email Successfully sent !"); @@ -32,7 +33,6 @@ export const SettingsEmailTab = (props: SettingsEmailTabProps) => { const handleSendMailTest = async () => { - console.log("Sending email test..."); await mutation.mutateAsync() } diff --git a/src/env.mjs b/src/env.mjs index 44defa09..4ea717f8 100644 --- a/src/env.mjs +++ b/src/env.mjs @@ -11,6 +11,8 @@ export const env = createEnv({ DATABASE_URL: z.string().url(), NEXT_PUBLIC_SECRET: z.string(), NEXTAUTH_URL: z.string(), + NEXT_PUBLIC_DOMAIN_NAME: z.string(), + SMTP_PASSWORD: z.string().optional(), SMTP_FROM: z.string().optional(), @@ -29,6 +31,7 @@ export const env = createEnv({ S3_USE_SSL: z.string().optional(), STORAGE_TYPE: z.string().optional(), + }, /* * Environment variables available on the client (and server). diff --git a/src/utils/email-helper.ts b/src/utils/email-helper.ts index 8334eada..000fdb29 100644 --- a/src/utils/email-helper.ts +++ b/src/utils/email-helper.ts @@ -2,14 +2,12 @@ import {prisma} from "@/prisma"; import nodemailer from "nodemailer"; - type Payload = { to: string; subject: string; html: any }; - export const sendEmail = async (data: Payload) => { const settings = await prisma.settings.findUnique({ @@ -18,7 +16,6 @@ export const sendEmail = async (data: Payload) => { } }) - const smtpSettings = { host: settings.smtpHost, port: parseInt(settings.smtpPort), @@ -28,15 +25,11 @@ export const sendEmail = async (data: Payload) => { }, }; - // Create a transporter object using nodemailer const transporter = nodemailer.createTransport({ ...smtpSettings }); - // Render the React component to HTML - // const emailHtml = await render(HelloEmail(), {}); - // Set up email options const mailOptions = { ...data