({
event,
data: { to, from, body, channelInbox, lastExternalMessageId, title },
}: {
event: string;
data: {
from?: string | null;
to?: string | null;
body: string;
channelInbox: string;
lastExternalMessageId?: string | null;
title?: string | null;
};
})
| 88 | } |
| 89 | |
| 90 | async function sendMail({ |
| 91 | event, |
| 92 | data: { to, from, body, channelInbox, lastExternalMessageId, title }, |
| 93 | }: { |
| 94 | event: string; |
| 95 | data: { |
| 96 | from?: string | null; |
| 97 | to?: string | null; |
| 98 | body: string; |
| 99 | channelInbox: string; |
| 100 | lastExternalMessageId?: string | null; |
| 101 | title?: string | null; |
| 102 | }; |
| 103 | }) { |
| 104 | const transporter = nodemailer.createTransport({ |
| 105 | host: process.env.EMAIL_BRIDGE_HOST!, |
| 106 | port: 465, |
| 107 | secure: true, |
| 108 | auth: { |
| 109 | user: process.env.EMAIL_BRIDGE_USER!, |
| 110 | pass: process.env.EMAIL_BRIDGE_PASS!, |
| 111 | }, |
| 112 | }); |
| 113 | |
| 114 | if (!to) { |
| 115 | return '"to" not found'; |
| 116 | } |
| 117 | const sendResponse = await transporter.sendMail({ |
| 118 | ...(lastExternalMessageId && { |
| 119 | inReplyTo: lastExternalMessageId, |
| 120 | }), |
| 121 | from: from ? `${from} ${channelInbox}` : channelInbox, |
| 122 | to: extractEmail(to)?.join(), |
| 123 | text: body, |
| 124 | subject: `Re: ${title}`, |
| 125 | }); |
| 126 | console.log(stringify(sendResponse)); |
| 127 | return parseResponse(sendResponse.response); |
| 128 | } |
no test coverage detected