@remit/imap-worker 0.0.37 → 0.0.38

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": "@remit/imap-worker",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@aws-sdk/client-s3": "^3.1055.0",
35
- "nodemailer": "^9.0.3",
36
35
  "@remit/data-ports": "*",
36
+ "@remit/smtp-service": "*",
37
37
  "@remit/logger-lambda": "*",
38
38
  "@remit/mailbox-service": "*",
39
39
  "@remit/search-index-worker": "*",
@@ -47,8 +47,7 @@
47
47
  "@aws-sdk/client-ssm": "*",
48
48
  "expect-env": "*",
49
49
  "p-map": "*",
50
- "@types/aws-lambda": "*",
51
- "@types/nodemailer": "*"
50
+ "@types/aws-lambda": "*"
52
51
  },
53
52
  "license": "MIT",
54
53
  "publishConfig": {
@@ -2,11 +2,13 @@ import { getClient } from "@remit/backend/client";
2
2
  import type {
3
3
  IMailboxRepository,
4
4
  IMailboxSpecialUseRepository,
5
- OutboxMessageItem,
6
5
  } from "@remit/data-ports";
7
6
  import { MailboxSpecialUse } from "@remit/domain-enums";
8
7
  import type { Logger } from "@remit/logger-lambda";
9
- import nodemailer from "nodemailer";
8
+ import {
9
+ buildMailMessage,
10
+ renderRawMessage,
11
+ } from "@remit/smtp-service/message-builder";
10
12
  import { isAccountDeleted } from "../account-check.js";
11
13
  import { createConnectionScopeWithCredentials } from "../connection-scope.js";
12
14
  import type { AppendSentMessageEvent } from "../events.js";
@@ -46,35 +48,6 @@ const findSentMailbox = async (
46
48
  return null;
47
49
  };
48
50
 
49
- const buildRawMessage = async (outbox: OutboxMessageItem): Promise<Buffer> => {
50
- const from = outbox.fromName
51
- ? `${outbox.fromName} <${outbox.fromAddress}>`
52
- : outbox.fromAddress;
53
-
54
- const transport = nodemailer.createTransport({ streamTransport: true });
55
-
56
- const info = await transport.sendMail({
57
- from,
58
- to: outbox.toAddresses.join(", "),
59
- cc: outbox.ccAddresses?.join(", "),
60
- bcc: outbox.bccAddresses?.join(", "),
61
- replyTo: outbox.replyToAddress,
62
- subject: outbox.subject,
63
- text: outbox.textBody,
64
- html: outbox.htmlBody,
65
- messageId: `<${outbox.messageIdValue}>`,
66
- inReplyTo: outbox.inReplyTo ? `<${outbox.inReplyTo}>` : undefined,
67
- references: outbox.references?.map((r) => `<${r}>`).join(" "),
68
- date: outbox.sentAt ? new Date(outbox.sentAt) : new Date(),
69
- });
70
-
71
- const chunks: Buffer[] = [];
72
- for await (const chunk of info.message as AsyncIterable<Buffer>) {
73
- chunks.push(chunk);
74
- }
75
- return Buffer.concat(chunks);
76
- };
77
-
78
51
  export interface AppendSentMessageDeps {
79
52
  getClient: typeof getClient;
80
53
  buildLifecycleDeps: typeof buildLifecycleDeps;
@@ -150,7 +123,7 @@ export const handleAppendSentMessage = async (
150
123
  await scope
151
124
  .getConnection()
152
125
  .then(async (connection) => {
153
- const rawMessage = await buildRawMessage(outbox);
126
+ const rawMessage = await renderRawMessage(buildMailMessage(outbox));
154
127
 
155
128
  const result = await connection.append(
156
129
  sentMailbox.fullPath,