mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
Working on sending email. Now ok.
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user