rebrand to useSend (#210)

This commit is contained in:
KM Koushik
2025-09-03 08:21:55 +10:00
committed by GitHub
parent b1a59d2705
commit 07c53d3f58
219 changed files with 1349 additions and 2835 deletions

View File

@@ -1,17 +1,17 @@
name: unsend-smtp-server
name: usesend-smtp-server
services:
smtp-server:
container_name: unsend-smtp-server
image: unsend/smtp-proxy:latest
container_name: usesend-smtp-server
image: usesend/smtp-proxy:latest
# Pass necessary environment variables
environment:
SMTP_AUTH_USERNAME: "unsend" # can be anything, just use the same while sending emails
UNSEND_BASE_URL: "https://app.unsend.dev" # your self hosted unsend instance url
SMTP_AUTH_USERNAME: "usesend" # can be anything, just use the same while sending emails
USESEND_BASE_URL: "https://app.usesend.com" # your self hosted useSend instance url
# Uncomment this if you have SSL certificates. port 465 and 2465 will be using SSL
# UNSEND_API_KEY_PATH: "/certs/server.key"
# UNSEND_API_CERT_PATH: "/certs/server.crt"
# USESEND_API_KEY_PATH: "/certs/server.key"
# USESEND_API_CERT_PATH: "/certs/server.crt"
# If you have SSL certificates, mount them here (read-only recommended)
# volumes:

View File

@@ -6,16 +6,21 @@ import { readFileSync, watch, FSWatcher } from "fs";
dotenv.config();
const AUTH_USERNAME = process.env.SMTP_AUTH_USERNAME ?? "unsend";
const UNSEND_BASE_URL = process.env.UNSEND_BASE_URL ?? "https://app.unsend.dev";
const SSL_KEY_PATH = process.env.UNSEND_API_KEY_PATH;
const SSL_CERT_PATH = process.env.UNSEND_API_CERT_PATH;
const AUTH_USERNAME = process.env.SMTP_AUTH_USERNAME ?? "usesend";
const BASE_URL =
process.env.USESEND_BASE_URL ??
process.env.UNSEND_BASE_URL ??
"https://app.usesend.com";
const SSL_KEY_PATH =
process.env.USESEND_API_KEY_PATH ?? process.env.UNSEND_API_KEY_PATH;
const SSL_CERT_PATH =
process.env.USESEND_API_CERT_PATH ?? process.env.UNSEND_API_CERT_PATH;
async function sendEmailToUnsend(emailData: any, apiKey: string) {
async function sendEmailToUseSend(emailData: any, apiKey: string) {
try {
const apiEndpoint = "/api/v1/emails";
const url = new URL(apiEndpoint, UNSEND_BASE_URL); // Combine base URL with endpoint
console.log("Sending email to Unsend API at:", url.href); // Debug statement
const url = new URL(apiEndpoint, BASE_URL); // Combine base URL with endpoint
console.log("Sending email to useSend API at:", url.href); // Debug statement
const emailDataText = JSON.stringify(emailData);
@@ -31,17 +36,17 @@ async function sendEmailToUnsend(emailData: any, apiKey: string) {
if (!response.ok) {
const errorData = await response.text();
console.error(
"Unsend API error response: error:",
"useSend API error response: error:",
JSON.stringify(errorData, null, 4),
`\nemail data: ${emailDataText}`
`\nemail data: ${emailDataText}`,
);
throw new Error(
`Failed to send email: ${errorData || "Unknown error from server"}`
`Failed to send email: ${errorData || "Unknown error from server"}`,
);
}
const responseData = await response.json();
console.log("Unsend API response:", responseData);
console.log("useSend API response:", responseData);
} catch (error) {
if (error instanceof Error) {
console.error("Error message:", error.message);
@@ -69,7 +74,7 @@ const serverOptions: SMTPServerOptions = {
onData(
stream: Readable,
session: SMTPServerSession,
callback: (error?: Error) => void
callback: (error?: Error) => void,
) {
console.log("Receiving email data..."); // Debug statement
simpleParser(stream, (err, parsed) => {
@@ -96,7 +101,7 @@ const serverOptions: SMTPServerOptions = {
replyTo: parsed.replyTo?.text,
};
sendEmailToUnsend(emailObject, session.user)
sendEmailToUseSend(emailObject, session.user)
.then(() => callback())
.then(() => console.log("Email sent successfully to: ", emailObject.to))
.catch((error) => {
@@ -128,7 +133,7 @@ function startServers() {
server.listen(port, () => {
console.log(
`Implicit SSL/TLS SMTP server is listening on port ${port}`
`Implicit SSL/TLS SMTP server is listening on port ${port}`,
);
});

View File

@@ -5,7 +5,7 @@ const transporter = nodemailer.createTransport({
port: 25,
secure: false,
auth: {
user: "unsend",
user: "usesend",
pass: "us_123",
},
tls: {
@@ -17,8 +17,8 @@ const mailOptions = {
to: "sender@example.com",
from: "hello@example.com",
subject: "Testing SMTP",
html: "<strong>THIS IS USING SMTP,</strong><p>Unsend is the best open source sending platform<p><p>check out <a href='https://unsend.dev'>unsend.dev</a>",
text: "hello,\n\nUnsend is the best open source sending platform",
html: "<strong>THIS IS USING SMTP,</strong><p>useSend is the best open source sending platform<p><p>check out <a href='https://usesend.com'>usesend.com</a>",
text: "hello,\n\nuseSend is the best open source sending platform",
};
transporter.sendMail(mailOptions, (error, info) => {