Closed ogheneovo12 closed 2 hours ago
Found the bug; i feel so foolish ATM
I had applied async to this.getSMTPConfig(doc)
when it shouldn't be an async method,
i didn't know why i had also assumed NodeMailer stored options as promise getter, even though i found it off initially,
const options = await this.mailerService['transporters']?.get(transporterName).options;
Apparently i was the one setting a promissive option
this.mailerService.addTransporter(
doc.workspace?._id?.toString(),
this.getSMTPConfig(doc), //Asynchronous
)
Describe the bug On module initialization, i set custom transporters to the transporters map. Using the transporterName later in sendMail, leads to connection Error.
see initialisation code below
The getSMTPConfig basically just decrypts auth credentials; I have verified that it returns actual configuration, which you will see reflected in sendMail.
with the above i get the below error
Now uncommenting the below portion of the above code, i.e., re-registering the transporter again from the options existing in the transport map, seems to work.
Now I am tempted to keep a map of transporters myself and add a transporter for every sendMail call, but that's not efficient.
Basically, the custom transporter only works if the transporter was added immediately after the sendMail is called.
The pre-registered transporters stored in memory should always work with the correct configurations.