I have successfully uploaded the Nodemailer npm dependency in my Mongo Realm functions and now trying to send an email when a document in my Users collection is added. I use the following code:
No. Unfortunately I couldn’t find a solution. What I did was to write my nodemailer code in my backend API (Express/NodeJs) and use the Realm trigger to send a request to that API endpoint instead.
I couldn’t make it work, I’ll probably end up doing the same as @Akbar_bakhshi1. Although it would be cool to be able to use this library in Realm functions.
Nodemailer has a dependency for Punycode which is currently an unsupported module in Realm Functions as mentioned in this article, and is likely the cause of the error.
Realm functions do not support the following built-in modules:
child_process
cluster
domain
punycode
readline
v8
vm
Our team is looking to provide Punycode support at some point in the future, however we do recommend using a service such as AWS SES for sending out emails. This will be a more reliable alternative especially if you are sending with high frequency/volume.