|
1 | 1 | import type { ResolvedSendConfig } from "../../config/mail/mod.ts";
|
2 | 2 | import { ResolvedClientOptions } from "../../config/client.ts";
|
3 |
| -import { encodeRelated } from "./encode/related.ts"; |
4 | 3 | import { SMTPConnection } from "./connection.ts";
|
5 | 4 | import { QUE } from "./QUE.ts";
|
6 | 5 |
|
@@ -247,7 +246,7 @@ export class SMTPClient {
|
247 | 246 | for (let i = 0; i < config.mimeContent.length; i++) {
|
248 | 247 | writeCMD(`--${messageBoundary}`);
|
249 | 248 | if (config.mimeContent[i].relatedAttachments) {
|
250 |
| - encodeRelated(writeCMD, config.mimeContent[i]); |
| 249 | + this.encodeRelated(config.mimeContent[i]); |
251 | 250 | } else {
|
252 | 251 | this.encodeContent(config.mimeContent[i]);
|
253 | 252 | }
|
@@ -282,6 +281,29 @@ export class SMTPClient {
|
282 | 281 | }
|
283 | 282 | }
|
284 | 283 |
|
| 284 | + encodeRelated(content: Content) { |
| 285 | + const boundaryAddRel = this.calcBoundary( |
| 286 | + content.content + "\n" + |
| 287 | + content.relatedAttachments.map((v) => v.content).join("\n"), |
| 288 | + new RegExp("--related([0-9]+)", "g"), |
| 289 | + ); |
| 290 | + |
| 291 | + const relatedBoundary = `related${boundaryAddRel}`; |
| 292 | + this.#connection.writeCmd( |
| 293 | + `Content-Type: multipart/related; boundary=${relatedBoundary}\r\n; type=${content.mimeType}`, |
| 294 | + ); |
| 295 | + |
| 296 | + this.#connection.writeCmd(`--${relatedBoundary}`); |
| 297 | + this.encodeContent(content); |
| 298 | + |
| 299 | + for (let i = 0; i < content.relatedAttachments.length; i++) { |
| 300 | + this.#connection.writeCmd(`--${relatedBoundary}`); |
| 301 | + this.encodeAttachment(content.relatedAttachments[i]); |
| 302 | + } |
| 303 | + |
| 304 | + this.#connection.writeCmd(`--${relatedBoundary}--\r\n`); |
| 305 | + } |
| 306 | + |
285 | 307 | async #prepareConnection() {
|
286 | 308 | this.#connection.assertCode(
|
287 | 309 | await this.#connection.readCmd(),
|
|
0 commit comments