Closed americrypt closed 4 years ago
It might be unintuitive but possible to get a reference for server
const server = new SMTPServer({
});
server.onMailFrom = (address, session, callback) => {
server.close();
};
I would not prefer adding server property to session object as the session object is supposed to be something that is serialisable, adding a complex object breaks that convention.
Yes, that's not intuitive, you're right.
@andris9 Thank you for your work on Nodemailer. Its been a lot of fun hacking on it.
This pull request solves a problem I encountered. I now fully understand how you are gracefully exiting the server, but I don't see any example code here nor on SO showing where most folks are calling
server.close()
in their implementations. Since the 6 implementation functions do not have a reference toserver
, I'm at a loss how anyone could callserver.close()
.For my implementation, I want to be able to connect to the server normally and issue a back-door command to kick off the graceful shutdown. This eliminates having to SSH into a server to issue commands that way. I chose
MAIL FROM
to implement the following:This solves my problem and may be useful to others, but I still would like to understand your vision for calling
server.close()
— where do you call it?Also, not sure why you have
this.session = this.session = {
on line 38? Maybe cut/paste got carried away? 💯 All tests passed BTW except the proxy / OpenSSL tests as I do not have openSSL on this Windows box. Again, thanks for maintaining this great project! 👍