@remit/smtp-service 0.0.14 → 0.0.15
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/smtp-client.test.ts +7 -3
- package/src/smtp-client.ts +8 -1
package/package.json
CHANGED
package/src/smtp-client.test.ts
CHANGED
|
@@ -158,9 +158,13 @@ describe("sendMail", () => {
|
|
|
158
158
|
);
|
|
159
159
|
});
|
|
160
160
|
|
|
161
|
-
it("throws a classified auth error on a 535 AUTH rejection", async () => {
|
|
161
|
+
it("throws a classified auth error on a 535 AUTH rejection, in the server's words", async () => {
|
|
162
|
+
// What Microsoft answers a tenant with SMTP AUTH switched off. Signing in
|
|
163
|
+
// again never clears it, so the text has to survive classification for the
|
|
164
|
+
// account card to say what actually has to change.
|
|
162
165
|
const server = await spawn({
|
|
163
|
-
authResponse:
|
|
166
|
+
authResponse:
|
|
167
|
+
"535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant\r\n",
|
|
164
168
|
});
|
|
165
169
|
|
|
166
170
|
await assert.rejects(
|
|
@@ -168,7 +172,7 @@ describe("sendMail", () => {
|
|
|
168
172
|
(error: unknown) => {
|
|
169
173
|
assert.ok(error instanceof SmtpConnectionError);
|
|
170
174
|
assert.equal(error.kind, "auth");
|
|
171
|
-
assert.
|
|
175
|
+
assert.match(error.message, /SmtpClientAuthentication is disabled/);
|
|
172
176
|
return true;
|
|
173
177
|
},
|
|
174
178
|
);
|
package/src/smtp-client.ts
CHANGED
|
@@ -111,6 +111,7 @@ export const sendMail = async (
|
|
|
111
111
|
responseCode?: number;
|
|
112
112
|
code?: string;
|
|
113
113
|
command?: string;
|
|
114
|
+
response?: string;
|
|
114
115
|
},
|
|
115
116
|
) => {
|
|
116
117
|
const smtpCode = error.responseCode;
|
|
@@ -122,9 +123,15 @@ export const sendMail = async (
|
|
|
122
123
|
smtpCode >= 500 &&
|
|
123
124
|
error.command === "AUTH")
|
|
124
125
|
) {
|
|
126
|
+
// The server's own words, when it gave any: a 535 reading
|
|
127
|
+
// "SmtpClientAuthentication is disabled for the Tenant" is not a
|
|
128
|
+
// failure signing in again clears, and the account card can only
|
|
129
|
+
// say so if the text survives the classification.
|
|
125
130
|
throw new SmtpConnectionError(
|
|
126
131
|
"auth",
|
|
127
|
-
|
|
132
|
+
error.response
|
|
133
|
+
? `SMTP authentication failed: ${error.response.trim()}`
|
|
134
|
+
: "SMTP authentication failed",
|
|
128
135
|
error,
|
|
129
136
|
);
|
|
130
137
|
}
|