arn-rawmime 0.1.11 → 0.1.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arn-rawmime",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "A lightweight, dependency-free raw MIME email builder with DKIM support.",
5
5
  "author": "ARNDESK",
6
6
  "type": "module",
@@ -87,6 +87,15 @@ class MimeMessage {
87
87
  return "utf8";
88
88
  }
89
89
 
90
+ _getBoundarySpacer() {
91
+ // Yahoo style uses a single CRLF (no empty line)
92
+ if (this.boundaryStyle === "yahoo_part") {
93
+ return "\r\n";
94
+ }
95
+ // Default to double CRLF (an empty line) for Gmail, Outlook, Apple Mail, etc.
96
+ return "\r\n\r\n";
97
+ }
98
+
90
99
  _encodeQuotedPrintable(str, bufferEncoding = "utf8") {
91
100
  if (!str) return "";
92
101
 
@@ -651,7 +660,7 @@ class MimeMessage {
651
660
  const numAttachments = this.attachments.length;
652
661
  const numBodyParts = this.bodyParts.length;
653
662
 
654
- // NOTE: Double \r\n\r\n added after content parts for visual separation
663
+ const spacer = this._getBoundarySpacer();
655
664
 
656
665
  // CASE 1: No Attachments (Multipart/Alternative)
657
666
  if (numAttachments === 0) {
@@ -663,7 +672,7 @@ class MimeMessage {
663
672
  body += `--${boundary}\r\n`;
664
673
  body += `Content-Type: ${part.contentType}; charset=${part.charset}\r\n`;
665
674
  body += `Content-Transfer-Encoding: ${part.encoding}\r\n\r\n`;
666
- body += part.data + "\r\n\r\n"; // Visual Gap
675
+ body += part.data + spacer;
667
676
  }
668
677
  body += `--${boundary}--`;
669
678
  } else if (numBodyParts === 1) {
@@ -691,15 +700,15 @@ class MimeMessage {
691
700
  body += `--${altBoundary}\r\n`;
692
701
  body += `Content-Type: ${part.contentType}; charset=${part.charset}\r\n`;
693
702
  body += `Content-Transfer-Encoding: ${part.encoding}\r\n\r\n`;
694
- body += part.data + "\r\n\r\n"; // Visual Gap
703
+ body += part.data + spacer;
695
704
  }
696
- body += `--${altBoundary}--\r\n\r\n`; // Gap after inner close
705
+ body += `--${altBoundary}--${spacer}`;
697
706
  } else {
698
707
  const part = this.bodyParts[0];
699
708
  body += `--${mixedBoundary}\r\n`;
700
709
  body += `Content-Type: ${part.contentType}; charset=${part.charset}\r\n`;
701
710
  body += `Content-Transfer-Encoding: ${part.encoding}\r\n\r\n`;
702
- body += part.data + "\r\n\r\n"; // Visual Gap
711
+ body += part.data + spacer;
703
712
  }
704
713
  }
705
714
 
@@ -711,7 +720,7 @@ class MimeMessage {
711
720
  body += `Content-Transfer-Encoding: ${att.encoding}\r\n`;
712
721
  body += `Content-ID: ${att.headers["Content-ID"]}\r\n`;
713
722
  body += `X-Attachment-Id: ${att.headers["X-Attachment-Id"]}\r\n\r\n`;
714
- body += att.data + "\r\n\r\n"; // Visual Gap
723
+ body += att.data + spacer;
715
724
  }
716
725
  body += `--${mixedBoundary}--`;
717
726
  }