stefandevo
stefandevo5mo ago

Convex auth with nodemailer for smtp

I want to use my own smtp server to send out the magic links, but it seems that the needed provider for this (nodemailer) is not working out of the box with convex. The issue is with stream, crypto, path, os, fs all not available - You can use "platform: 'node'" to do that, which will remove this error. But I guess that's not an option, or is it?
4 Replies
jamwt
jamwt5mo ago
hi there! yeah, unfortunately anything that requires true e.g. filesystem access (node.js's fs or whatever) will not work in the convex function environment. our node runtime uses aws lambda, and the filesystem is ephemeral and read-only, so npm packages which are going to want to try to use the filesystem won't work
jamwt
jamwt5mo ago
convex's node environment is pretty comparable to like vercel's edge environment, so a lot of the same issues and solutions apply. i.e., https://github.com/nextauthjs/next-auth/issues/8357
GitHub
EmailProvider + nodemailer fails with Vercel Edge Runtime due to No...
Environment System: OS: Linux 5.19 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish) CPU: (4) x64 Intel(R) Core(TM) i7-10600U CPU @ 2.80GHz Memory: 1.86 GB / 16.00 GB Container: Yes Shell: 5.8.1 - /...
jamwt
jamwt5mo ago
you could probably manually use something like this ( https://www.npmjs.com/package/smtp-client ) in an action, with your own retry logic. I'm guessing nodemailer is using the filesystem to persist and retry communication with the target smtp server if there are temporary failures
npm
smtp-client
Low level SMTP communication layer.. Latest version: 0.4.0, last published: 3 years ago. Start using smtp-client in your project by running npm i smtp-client. There are 12 other projects in the npm registry using smtp-client.
stefandevo
stefandevoOP5mo ago
Ok thx for the info!

Did you find this page helpful?