Allow separate from and to emails
All checks were successful
Publish Docker Image / Publish Docker Image (push) Successful in 10s

This commit is contained in:
Ahmed Al-Taiar
2024-10-16 21:45:55 -04:00
parent 6540329f36
commit 7973663b2a
7 changed files with 21 additions and 3 deletions

View File

@ -22,6 +22,8 @@ SMTP_HOST=smtp.example.com
SMTP_PORT=465 SMTP_PORT=465
SMTP_SECURE=true SMTP_SECURE=true
SMTP_USER=noreply@example.com SMTP_USER=noreply@example.com
EMAIL_FROM=noreply@example.com
EMAIL_TO=email@example.com
SMTP_PASSWORD=password SMTP_PASSWORD=password
DOMAIN=example.com DOMAIN=example.com

View File

@ -10,6 +10,8 @@ SMTP_HOST=smtp.example.com
SMTP_PORT=465 SMTP_PORT=465
SMTP_SECURE=true SMTP_SECURE=true
SMTP_USER=noreply@example.com SMTP_USER=noreply@example.com
EMAIL_FROM=noreply@example.com
EMAIL_TO=email@example.com
SMTP_PASSWORD=password SMTP_PASSWORD=password
DOMAIN=example.com DOMAIN=example.com

View File

@ -48,6 +48,8 @@ ARG SMTP_PORT
ARG SMTP_SECURE ARG SMTP_SECURE
ARG SMTP_USER ARG SMTP_USER
ARG SMTP_PASSWORD ARG SMTP_PASSWORD
ARG EMAIL_FROM
ARG EMAIL_TO
ARG FIRST_NAME ARG FIRST_NAME
ARG LAST_NAME ARG LAST_NAME

View File

@ -28,6 +28,8 @@ services:
- SMTP_PORT=465 - SMTP_PORT=465
- SMTP_SECURE=true - SMTP_SECURE=true
- SMTP_USER=noreply@example.com - SMTP_USER=noreply@example.com
- EMAIL_FROM=noreply@example.com
- EMAIL_TO=email@example.com
- SMTP_PASSWORD=password - SMTP_PASSWORD=password
- DOMAIN=portfolio.example.com - DOMAIN=portfolio.example.com
- API_DOMAIN=api.portfolio.example.com - API_DOMAIN=api.portfolio.example.com

View File

@ -19,7 +19,7 @@ const transporter = nodemailer.createTransport({
export const sendEmail = async ({ to, subject, text, html }: Options) => export const sendEmail = async ({ to, subject, text, html }: Options) =>
await transporter.sendMail({ await transporter.sendMail({
from: `${process.env.FIRST_NAME} ${process.env.LAST_NAME} <${process.env.GMAIL}>`, from: `${process.env.FIRST_NAME} ${process.env.LAST_NAME} <${process.env.EMAIL_FROM}>`,
to: Array.isArray(to) ? to : [to], to: Array.isArray(to) ? to : [to],
subject, subject,
text, text,

View File

@ -16,6 +16,8 @@ services:
- SMTP_PORT=465 - SMTP_PORT=465
- SMTP_SECURE=true - SMTP_SECURE=true
- SMTP_USER=noreply@example.com - SMTP_USER=noreply@example.com
- EMAIL_FROM=noreply@example.com
- EMAIL_TO=email@example.com
- SMTP_PASSWORD=password - SMTP_PASSWORD=password
- DOMAIN=portfolio.example.com - DOMAIN=portfolio.example.com
- API_DOMAIN=api.portfolio.example.com - API_DOMAIN=api.portfolio.example.com

View File

@ -9,7 +9,7 @@ export default async () => {
try { try {
const admin = { const admin = {
username: 'admin', username: 'admin',
email: process.env.GMAIL, email: process.env.EMAIL_TO,
password: process.env.SMTP_PASSWORD, password: process.env.SMTP_PASSWORD,
} }
@ -17,7 +17,7 @@ export default async () => {
const existingAdmin = await db.user.findFirst({ const existingAdmin = await db.user.findFirst({
where: { where: {
email: admin.email, username: admin.username,
}, },
}) })
@ -30,6 +30,14 @@ export default async () => {
salt, salt,
}, },
}) })
else
await db.user.update({
where: { id: existingAdmin.id },
data: {
username: admin.username,
email: admin.email,
},
})
const titles = await db.titles.findFirst() const titles = await db.titles.findFirst()