diff --git a/src/assets/logo.png b/src/assets/logo.png
new file mode 100644
index 0000000..e3bc710
Binary files /dev/null and b/src/assets/logo.png differ
diff --git a/src/services/email.js b/src/services/email.js
index 02b8887..6e58fca 100644
--- a/src/services/email.js
+++ b/src/services/email.js
@@ -1,4 +1,7 @@
import nodemailer from 'nodemailer';
+import { readFileSync } from 'fs';
+import { fileURLToPath } from 'url';
+import { dirname, join } from 'path';
/**
* Create a Nodemailer transport using SMTP environment variables.
@@ -36,11 +39,39 @@ const createTransport = () => {
});
};
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = dirname(__filename);
+
+/**
+ * Read the logo PNG file for embedding in emails.
+ * Returns a Buffer, or null if the file doesn't exist.
+ */
+let _logoBuffer = null;
+const getLogoBuffer = () => {
+ if (_logoBuffer) return _logoBuffer;
+ try {
+ _logoBuffer = readFileSync(join(__dirname, '..', 'assets', 'logo.png'));
+ } catch {
+ // silently ignore if logo file is not found
+ }
+ return _logoBuffer;
+};
+
const getFromAddress = () =>
process.env.SMTP_FROM || process.env.SMTP_USER;
+/**
+ * Return just the bare email address (used for envelope sender).
+ * Strips any display-name or angle brackets from SMTP_FROM.
+ */
+const getFromEmail = () => {
+ const raw = process.env.SMTP_FROM || process.env.SMTP_USER;
+ const match = raw.match(/<([^>]+)>/);
+ return match ? match[1] : raw;
+};
+
const getContactEmail = () =>
- process.env.CONTACT_EMAIL || process.env.SMTP_USER;
+ process.env.CONTACT_EMAIL || getFromEmail();
/**
* Verify that the SMTP transport can connect.
@@ -78,7 +109,7 @@ export const sendContactEmail = async ({ name, email, company, message }) => {
const companyLine = company ? `Company: ${company}\n` : '';
const info = await transporter.sendMail({
- from: `"Moxie Contact Form" <${from}>`,
+ from: `"Moxie Contact Form" <${getFromEmail()}>`,
to,
replyTo: email, // allow replying directly to the submitter
subject: `[Moxie] New Contact Form Submission from ${name}`,
@@ -143,12 +174,27 @@ export const sendContactEmail = async ({ name, email, company, message }) => {
export const sendAutoReply = async ({ name, email }) => {
try {
const transporter = createTransport();
- const from = getFromAddress();
+ const logoBuf = getLogoBuffer();
+
+ // Build attachments array — logo as CID if available
+ const attachments = [];
+ const logoHtmlTag = logoBuf
+ ? ''
+ : 'Moxiegen';
+
+ if (logoBuf) {
+ attachments.push({
+ filename: 'logo.png',
+ content: logoBuf,
+ cid: 'moxiegen-logo', // same CID as referenced in the HTML img tag
+ });
+ }
const info = await transporter.sendMail({
- from: `"Moxiegen" <${from}>`,
+ from: `"Moxiegen" <${getFromEmail()}>`,
to: email,
subject: 'Thank you for contacting Moxiegen',
+ attachments,
text: [
`Dear ${name},`,
'',
@@ -171,7 +217,7 @@ export const sendAutoReply = async ({ name, email }) => {
html: `
Algorithmic Enhancement for Enterprise AI
Need a faster response?
- Call us at +1 (855) 246-6943 or email - info@moxiegen.com + Call us at +1 (855) 246-6943 or email info@moxiegen.com