@iola_adm/iola-cli 0.2.25 → 0.2.26
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 +1 -1
- package/src/cli.js +11 -1
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -4038,7 +4038,7 @@ async function yandexMailSend(args = {}) {
|
|
|
4038
4038
|
await smtpCommand(session, `MAIL FROM:<${email}>`);
|
|
4039
4039
|
for (const recipient of to) await smtpCommand(session, `RCPT TO:<${recipient}>`);
|
|
4040
4040
|
await smtpCommand(session, "DATA", { expect: /^354/u });
|
|
4041
|
-
await smtpCommand(session, `${buildMimeMessage({ from: email, to, subject, text })}\r\n.`);
|
|
4041
|
+
await smtpCommand(session, `${dotStuffSmtpData(buildMimeMessage({ from: email, to, subject, text }))}\r\n.`);
|
|
4042
4042
|
await smtpCommand(session, "QUIT").catch(() => {});
|
|
4043
4043
|
return { from: email, to, subject, status: "sent" };
|
|
4044
4044
|
} finally {
|
|
@@ -4052,18 +4052,28 @@ function buildXoauth2(email, token) {
|
|
|
4052
4052
|
|
|
4053
4053
|
function buildMimeMessage({ from, to, subject, text }) {
|
|
4054
4054
|
const encodedSubject = Buffer.from(subject, "utf8").toString("base64");
|
|
4055
|
+
const messageIdDomain = String(from || "").split("@")[1] || "localhost";
|
|
4056
|
+
const messageId = `${randomUUID()}@${messageIdDomain}`;
|
|
4055
4057
|
return [
|
|
4056
4058
|
`From: ${from}`,
|
|
4057
4059
|
`To: ${to.join(", ")}`,
|
|
4060
|
+
`Reply-To: ${from}`,
|
|
4058
4061
|
`Subject: =?UTF-8?B?${encodedSubject}?=`,
|
|
4062
|
+
`Date: ${new Date().toUTCString()}`,
|
|
4063
|
+
`Message-ID: <${messageId}>`,
|
|
4059
4064
|
"MIME-Version: 1.0",
|
|
4060
4065
|
"Content-Type: text/plain; charset=utf-8",
|
|
4061
4066
|
"Content-Transfer-Encoding: base64",
|
|
4067
|
+
"X-Mailer: IOLA CLI",
|
|
4062
4068
|
"",
|
|
4063
4069
|
Buffer.from(text.replace(/\r?\n/g, "\r\n"), "utf8").toString("base64").replace(/.{1,76}/g, "$&\r\n").trim(),
|
|
4064
4070
|
].join("\r\n");
|
|
4065
4071
|
}
|
|
4066
4072
|
|
|
4073
|
+
function dotStuffSmtpData(message) {
|
|
4074
|
+
return String(message || "").replace(/\r?\n/g, "\r\n").replace(/(^|\r\n)\./g, "$1..");
|
|
4075
|
+
}
|
|
4076
|
+
|
|
4067
4077
|
function imapConnect() {
|
|
4068
4078
|
return tlsLineSession("imap.yandex.ru", 993, "* OK");
|
|
4069
4079
|
}
|