Skip to content

Commit dc3359e

Browse files
authored
🤖 Merge PR DefinitelyTyped#74704 feat(smtp-server): add hideDSN option and message param to onData cal… by @Mullayam
1 parent 1b29c8b commit dc3359e

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

‎types/smtp-server/index.d.ts‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ export interface SMTPServerOptions extends tls.TlsOptions {
209209
* Enhanced status codes are disabled by default.
210210
*/
211211
hideENHANCEDSTATUSCODES?: boolean | undefined;
212+
/**
213+
* optional boolean, if set to true then does not show DSN in features list, by default DSN is disabled
214+
*/
215+
hideDSN?: boolean;
212216
/**
213217
* optional boolean, if set to true allows authentication even if connection is not secured first
214218
*/
@@ -295,7 +299,11 @@ export interface SMTPServerOptions extends tls.TlsOptions {
295299
/**
296300
* the callback to handle incoming messages ([see details](https://nodemailer.com/extras/smtp-server#processing-incoming-messages-ondata))
297301
*/
298-
onData?(stream: SMTPServerDataStream, session: SMTPServerSession, callback: (err?: Error | null) => void): void;
302+
onData?(
303+
stream: SMTPServerDataStream,
304+
session: SMTPServerSession,
305+
callback: (err?: Error | null, message?: string) => void,
306+
): void;
299307
/**
300308
* the callback that informs about closed client connection
301309
*/
@@ -339,7 +347,11 @@ export class SMTPServer extends EventEmitter {
339347
/** Override this */
340348
onConnect(session: SMTPServerSession, callback: (err?: Error | null) => void): void;
341349
/** Override this */
342-
onData(stream: SMTPServerDataStream, session: SMTPServerSession, callback: (err?: Error | null) => void): void;
350+
onData(
351+
stream: SMTPServerDataStream,
352+
session: SMTPServerSession,
353+
callback: (err?: Error | null, message?: string) => void,
354+
): void;
343355
/** Override this */
344356
onMailFrom(address: SMTPServerAddress, session: SMTPServerSession, callback: (err?: Error | null) => void): void;
345357
/** Override this */

‎types/smtp-server/smtp-server-tests.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,17 @@ function test_newly_added_options() {
190190
},
191191
});
192192
}
193+
194+
function test_hideDSN_option() {
195+
const smtpServerInstance = new SMTPServer({
196+
hideDSN: true,
197+
});
198+
}
199+
200+
function test_onData_with_message() {
201+
const smtpServerInstance = new SMTPServer({
202+
onData(stream, session, callback) {
203+
callback(null, "Message queued");
204+
},
205+
});
206+
}

0 commit comments

Comments
 (0)