fix: add and change many email-related environment variables

This commit is contained in:
Dorian Niemiec 2024-09-07 11:08:25 +02:00
parent 3ffb81d020
commit e961bd557c
4 changed files with 23 additions and 16 deletions

View file

@ -8,8 +8,14 @@ ADMIN_PASSWORD=
NEXTAUTH_SECRET=
EMAIL=
EMAIL_SERVER=
EMAIL_PORT=
EMAIL_SECURE=
EMAIL_USER=
EMAIL_PASS=
EMAIL_NEWSLETTER_ADDRESS=
EMAIL_CONTACT_ADDRESS=
EMAIL_CONTACT_DEST=
SANITY_PROJECT_ID=

View file

@ -3,11 +3,11 @@ import nodemailer from "nodemailer";
import clientPromise from "@/lib/db";
const transporter = nodemailer.createTransport({
host: "smtp.ethereal.email", //replace this also comment this if u not using etheral
// service: "gmail", // uncomment if u using gmail
port: 587,
host: process.env.EMAIL_SERVER,
port: parseInt(process.env.EMAIL_PORT ? process.env.EMAIL_PORT : "25"),
secure: Boolean(process.env.EMAIL_SECURE ? process.env.EMAIL_SECURE : false),
auth: {
user: process.env.EMAIL,
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS
}
});
@ -15,7 +15,7 @@ const transporter = nodemailer.createTransport({
const sendEmail = async (to: string[], subject: string, html: string) => {
try {
await transporter.sendMail({
from: process.env.EMAIL_USER,
from: process.env.EMAIL_NEWSLETTER_ADDRESS,
to: to.join(", "),
subject: subject,
html: html

View file

@ -2,11 +2,11 @@ import { NextRequest, NextResponse } from "next/server";
import nodemailer from "nodemailer";
const transporter = nodemailer.createTransport({
host: "smtp.ethereal.email", // Replace with your SMTP host
// service: "gmail", // Uncomment if using Gmail
port: 587,
host: process.env.EMAIL_SERVER,
port: parseInt(process.env.EMAIL_PORT ? process.env.EMAIL_PORT : "25"),
secure: Boolean(process.env.EMAIL_SECURE ? process.env.EMAIL_SECURE : false),
auth: {
user: process.env.EMAIL,
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS
}
});
@ -14,7 +14,7 @@ const transporter = nodemailer.createTransport({
const sendEmail = async (to: string[], subject: string, html: string) => {
try {
await transporter.sendMail({
from: process.env.EMAIL_USER,
from: process.env.EMAIL_NEWSLETTER_ADDRESS,
to: to.join(", "),
subject: subject,
html: html

View file

@ -1,17 +1,18 @@
import nodemailer from "nodemailer";
export const transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,
host: process.env.EMAIL_SERVER,
port: parseInt(process.env.EMAIL_PORT ? process.env.EMAIL_PORT : "25"),
secure: Boolean(process.env.EMAIL_SECURE ? process.env.EMAIL_SECURE : false),
auth: {
user: process.env.EMAIL,
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS
}
});
export const mailOptions = {
from: process.env.EMAIL,
to: process.env.EMAIL,
from: process.env.EMAIL_CONTACT_ADDRESS,
to: process.env.EMAIL_CONTACT_DEST,
html: `
<table bgcolor="#fafafa" style=" width: 100%!important; height: 100%; background-color: #fafafa; padding: 20px; font-family: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 100%; line-height: 1.6;">
<tr>