dockerize smtp-proxy (#118)

This commit is contained in:
KM Koushik
2025-03-20 21:56:12 +11:00
committed by GitHub
parent 5465e2ec74
commit ecd28428d2
5 changed files with 141 additions and 53 deletions

View File

@@ -81,10 +81,9 @@ const serverOptions: SMTPServerOptions = {
replyTo: parsed.replyTo?.text,
};
console.log("Parsed email data:", emailObject); // Debug statement
sendEmailToUnsend(emailObject, session.user)
.then(() => callback())
.then(() => console.log("Email sent successfully to: ", emailObject.to))
.catch((error) => {
console.error("Failed to send email:", error.message);
callback(error);
@@ -104,18 +103,22 @@ const serverOptions: SMTPServerOptions = {
};
function startServers() {
// Implicit SSL/TLS for ports 465 and 2465
[465, 2465].forEach((port) => {
const server = new SMTPServer({ ...serverOptions, secure: true });
if (SSL_KEY_PATH && SSL_CERT_PATH) {
// Implicit SSL/TLS for ports 465 and 2465
[465, 2465].forEach((port) => {
const server = new SMTPServer({ ...serverOptions, secure: true });
server.listen(port, () => {
console.log(`Implicit SSL/TLS SMTP server is listening on port ${port}`);
});
server.listen(port, () => {
console.log(
`Implicit SSL/TLS SMTP server is listening on port ${port}`
);
});
server.on("error", (err) => {
console.error(`Error occurred on port ${port}:`, err);
server.on("error", (err) => {
console.error(`Error occurred on port ${port}:`, err);
});
});
});
}
// STARTTLS for ports 25, 587, and 2587
[25, 587, 2587].forEach((port) => {

View File

@@ -1,8 +1,8 @@
const nodemailer = require("nodemailer");
const transporter = nodemailer.createTransport({
host: "smtp.unsend.dev",
port: 2587,
host: "localhost",
port: 25,
secure: false,
auth: {
user: "unsend",