@lengelhard/imap-email-mcp 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +20 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -130,6 +130,20 @@ const SMTP_CONFIG = {
130
130
  }
131
131
  };
132
132
 
133
+ // Optional display name for outgoing mail. When unset, behaviour is unchanged
134
+ // and the From header is the bare address.
135
+ const SENDER_NAME = process.env.SENDER_NAME || '';
136
+
137
+ // Build an RFC 5322 From value. ASCII names are quoted; anything else is
138
+ // encoded as an RFC 2047 encoded-word so accents survive transport.
139
+ function formatFrom(address) {
140
+ if (!SENDER_NAME) return address;
141
+ const name = /^[\x20-\x7E]*$/.test(SENDER_NAME)
142
+ ? `"${SENDER_NAME.replace(/["\\]/g, '\\$&')}"`
143
+ : `=?UTF-8?B?${Buffer.from(SENDER_NAME, 'utf8').toString('base64')}?=`;
144
+ return `${name} <${address}>`;
145
+ }
146
+
133
147
  // Traverse the raw IMAP MIME struct to find all attachment parts.
134
148
  //
135
149
  // Detection rules (in priority order):
@@ -1134,7 +1148,7 @@ async function handleTool(name, args) {
1134
1148
  // Build RFC 2822 compliant email message
1135
1149
  const boundary = `----=_Part_${Date.now()}`;
1136
1150
  let message = '';
1137
- message += `From: ${IMAP_CONFIG.imap.user}\r\n`;
1151
+ message += `From: ${formatFrom(IMAP_CONFIG.imap.user)}\r\n`;
1138
1152
  message += `To: ${args.to}\r\n`;
1139
1153
  if (args.cc) message += `Cc: ${args.cc}\r\n`;
1140
1154
  if (args.bcc) message += `Bcc: ${args.bcc}\r\n`;
@@ -1180,7 +1194,7 @@ async function handleTool(name, args) {
1180
1194
 
1181
1195
  const boundary = `----=_Part_${Date.now()}`;
1182
1196
  let message = '';
1183
- message += `From: ${IMAP_CONFIG.imap.user}\r\n`;
1197
+ message += `From: ${formatFrom(IMAP_CONFIG.imap.user)}\r\n`;
1184
1198
  message += `To: ${args.to}\r\n`;
1185
1199
  if (args.cc) message += `Cc: ${args.cc}\r\n`;
1186
1200
  if (args.bcc) message += `Bcc: ${args.bcc}\r\n`;
@@ -1221,7 +1235,9 @@ async function handleTool(name, args) {
1221
1235
  const transporter = nodemailer.createTransport(SMTP_CONFIG);
1222
1236
 
1223
1237
  const mailOptions = {
1224
- from: SMTP_CONFIG.auth.user,
1238
+ from: SENDER_NAME
1239
+ ? { name: SENDER_NAME, address: SMTP_CONFIG.auth.user }
1240
+ : SMTP_CONFIG.auth.user,
1225
1241
  to: args.to,
1226
1242
  subject: args.subject,
1227
1243
  text: args.body,
@@ -1238,7 +1254,7 @@ async function handleTool(name, args) {
1238
1254
  const sentDate = new Date();
1239
1255
  const boundary = `----=_Part_${Date.now()}`;
1240
1256
  let rawMessage = '';
1241
- rawMessage += `From: ${SMTP_CONFIG.auth.user}\r\n`;
1257
+ rawMessage += `From: ${formatFrom(SMTP_CONFIG.auth.user)}\r\n`;
1242
1258
  rawMessage += `To: ${args.to}\r\n`;
1243
1259
  if (args.cc) rawMessage += `Cc: ${args.cc}\r\n`;
1244
1260
  if (args.bcc) rawMessage += `Bcc: ${args.bcc}\r\n`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lengelhard/imap-email-mcp",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "MCP server for Claude Code that provides email capabilities through IMAP/SMTP. Read, search, compose, and manage emails from any IMAP provider.",
5
5
  "type": "module",
6
6
  "main": "index.js",