@weijingwei/email 1.0.4 → 1.0.6

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.
package/dist/bundle.js CHANGED
@@ -82590,6 +82590,10 @@ function validateSmtpConfig(config2) {
82590
82590
  // src/services/imap.ts
82591
82591
  var import_imap_simple = __toESM(require_imap_simple());
82592
82592
  var import_mailparser = __toESM(require_mailparser());
82593
+ function isNeteaseMailbox(host) {
82594
+ const neteasePatterns = ["163.com", "126.com", "netease.com", "188.com"];
82595
+ return neteasePatterns.some((pattern) => host.includes(pattern));
82596
+ }
82593
82597
  function createImapConfig(config2) {
82594
82598
  return {
82595
82599
  imap: {
@@ -82608,7 +82612,23 @@ function createImapConfig(config2) {
82608
82612
  }
82609
82613
  async function connectImap(config2) {
82610
82614
  const imapConfig = createImapConfig(config2);
82611
- return await import_imap_simple.default.connect(imapConfig);
82615
+ const connection = await import_imap_simple.default.connect(imapConfig);
82616
+ if (isNeteaseMailbox(config2.host) && connection.imap.serverSupports("ID")) {
82617
+ await new Promise((resolve, reject) => {
82618
+ connection.imap.id({
82619
+ name: "EmailMCP",
82620
+ version: "1.0",
82621
+ vendor: "Weijingwei",
82622
+ "support-email": config2.username
82623
+ }, (err) => {
82624
+ if (err)
82625
+ reject(err);
82626
+ else
82627
+ resolve();
82628
+ });
82629
+ });
82630
+ }
82631
+ return connection;
82612
82632
  }
82613
82633
  async function listEmails(imapConfig, folder = "INBOX", page = 1, pageSize = 20) {
82614
82634
  const connection = await connectImap(imapConfig);
@@ -82731,7 +82751,7 @@ async function getEmail(imapConfig, uid, folder = "INBOX") {
82731
82751
  return {
82732
82752
  uid,
82733
82753
  from: parsed.from?.text || "",
82734
- to: parsed.to?.map((a) => a.text) || [],
82754
+ to: extractAddresses(parsed.to),
82735
82755
  subject: parsed.subject || "(\u65E0\u4E3B\u9898)",
82736
82756
  date: parsed.date?.toISOString() || "",
82737
82757
  flags: item.attributes.flags || [],
@@ -82744,6 +82764,17 @@ async function getEmail(imapConfig, uid, folder = "INBOX") {
82744
82764
  connection.end();
82745
82765
  }
82746
82766
  }
82767
+ function extractAddresses(address) {
82768
+ if (!address)
82769
+ return [];
82770
+ if (Array.isArray(address)) {
82771
+ return address.map((a) => a.text);
82772
+ }
82773
+ if (typeof address === "object" && "text" in address) {
82774
+ return [address.text];
82775
+ }
82776
+ return [];
82777
+ }
82747
82778
  function extractAttachmentInfo(parsed) {
82748
82779
  if (!parsed.attachments || parsed.attachments.length === 0) {
82749
82780
  return [];
package/dist/cli.js CHANGED
@@ -65636,6 +65636,10 @@ async function testSmtpConnection(config) {
65636
65636
  // src/services/imap.ts
65637
65637
  var import_imap_simple = __toESM(require_imap_simple());
65638
65638
  var import_mailparser = __toESM(require_mailparser());
65639
+ function isNeteaseMailbox(host) {
65640
+ const neteasePatterns = ["163.com", "126.com", "netease.com", "188.com"];
65641
+ return neteasePatterns.some((pattern) => host.includes(pattern));
65642
+ }
65639
65643
  function createImapConfig(config) {
65640
65644
  return {
65641
65645
  imap: {
@@ -65654,7 +65658,23 @@ function createImapConfig(config) {
65654
65658
  }
65655
65659
  async function connectImap(config) {
65656
65660
  const imapConfig = createImapConfig(config);
65657
- return await import_imap_simple.default.connect(imapConfig);
65661
+ const connection = await import_imap_simple.default.connect(imapConfig);
65662
+ if (isNeteaseMailbox(config.host) && connection.imap.serverSupports("ID")) {
65663
+ await new Promise((resolve, reject) => {
65664
+ connection.imap.id({
65665
+ name: "EmailMCP",
65666
+ version: "1.0",
65667
+ vendor: "Weijingwei",
65668
+ "support-email": config.username
65669
+ }, (err) => {
65670
+ if (err)
65671
+ reject(err);
65672
+ else
65673
+ resolve();
65674
+ });
65675
+ });
65676
+ }
65677
+ return connection;
65658
65678
  }
65659
65679
  async function listEmails(imapConfig, folder = "INBOX", page = 1, pageSize = 20) {
65660
65680
  const connection = await connectImap(imapConfig);
@@ -65777,7 +65797,7 @@ async function getEmail(imapConfig, uid, folder = "INBOX") {
65777
65797
  return {
65778
65798
  uid,
65779
65799
  from: parsed.from?.text || "",
65780
- to: parsed.to?.map((a) => a.text) || [],
65800
+ to: extractAddresses(parsed.to),
65781
65801
  subject: parsed.subject || "(\u65E0\u4E3B\u9898)",
65782
65802
  date: parsed.date?.toISOString() || "",
65783
65803
  flags: item.attributes.flags || [],
@@ -65790,6 +65810,17 @@ async function getEmail(imapConfig, uid, folder = "INBOX") {
65790
65810
  connection.end();
65791
65811
  }
65792
65812
  }
65813
+ function extractAddresses(address) {
65814
+ if (!address)
65815
+ return [];
65816
+ if (Array.isArray(address)) {
65817
+ return address.map((a) => a.text);
65818
+ }
65819
+ if (typeof address === "object" && "text" in address) {
65820
+ return [address.text];
65821
+ }
65822
+ return [];
65823
+ }
65793
65824
  function extractAttachmentInfo(parsed) {
65794
65825
  if (!parsed.attachments || parsed.attachments.length === 0) {
65795
65826
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weijingwei/email",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Email MCP Server - SMTP/IMAP email operations via MCP protocol",
5
5
  "main": "dist/bundle.js",
6
6
  "bin": {