Compare commits
5 Commits
cdf1c97fb8
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8616d8e6f4 | |||
| cc317ef83d | |||
| f42f6ada8e | |||
| 2d64c53e52 | |||
| 9639187067 |
@@ -3,5 +3,8 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "4321:4321"
|
||||
environment:
|
||||
- EMAIL_TO=${EMAIL_TO:-destinatary}
|
||||
- EMAIL_FROM=${EMAIL_FROM:-owner}
|
||||
- EMAIL_USER=${EMAIL_USER:-user}
|
||||
- EMAIL_PASS=${EMAIL_PASS:-password}
|
||||
|
||||
@@ -4,41 +4,41 @@ import nodemailer from "nodemailer";
|
||||
import emailTemplate from "../templates/emailTemplate.html?raw";
|
||||
|
||||
const transporter = nodemailer.createTransport({
|
||||
service: "gmail",
|
||||
auth: {
|
||||
user: import.meta.env.EMAIL_USER,
|
||||
pass: import.meta.env.EMAIL_PASS,
|
||||
},
|
||||
service: "gmail",
|
||||
auth: {
|
||||
user: import.meta.env.EMAIL_USER,
|
||||
pass: import.meta.env.EMAIL_PASS,
|
||||
},
|
||||
});
|
||||
|
||||
export const server = {
|
||||
sendEmail: defineAction({
|
||||
input: z.object({
|
||||
userName: z.string(),
|
||||
companyName: z.string(),
|
||||
phoneNumber: z.string(),
|
||||
userEmail: z.string().email(),
|
||||
}),
|
||||
sendEmail: defineAction({
|
||||
input: z.object({
|
||||
userName: z.string(),
|
||||
companyName: z.string(),
|
||||
phoneNumber: z.string(),
|
||||
userEmail: z.string().email(),
|
||||
}),
|
||||
|
||||
handler: async (input) => {
|
||||
const mailOptions = {
|
||||
from: '"Juan Diego" <jdcorreosvarios@gmail.com>',
|
||||
to: "jdcorreosvarios@gmail.com",
|
||||
subject: `Nueva persona interesada en Naliia: ${input.userName}`,
|
||||
html: emailTemplate
|
||||
.replace("{{userName}}", input.userName)
|
||||
.replace("{{companyName}}", input.companyName)
|
||||
.replace("{{phoneNumber}}", input.phoneNumber)
|
||||
.replace("{{userEmail}}", input.userEmail),
|
||||
};
|
||||
handler: async (input) => {
|
||||
const mailOptions = {
|
||||
from: import.meta.env.EMAIL_FROM,
|
||||
to: import.meta.env.EMAIL_TO,
|
||||
subject: `Nueva persona interesada en Naliia: ${input.userName}`,
|
||||
html: emailTemplate
|
||||
.replace("{{userName}}", input.userName)
|
||||
.replace("{{companyName}}", input.companyName)
|
||||
.replace("{{phoneNumber}}", input.phoneNumber)
|
||||
.replace("{{userEmail}}", input.userEmail),
|
||||
};
|
||||
|
||||
try {
|
||||
await transporter.sendMail(mailOptions);
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Error al enviar el correo:", error);
|
||||
throw new Error("Error al enviar el correo");
|
||||
}
|
||||
},
|
||||
}),
|
||||
try {
|
||||
await transporter.sendMail(mailOptions);
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
console.error("Error al enviar el correo:", error);
|
||||
throw new Error("Error al enviar el correo");
|
||||
}
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user