Is it possible to send mail in a worker ?

Hi, I'm looking to send mail from a worker where SMTP identifiers would be dynamic because I have several addresses from an API. I just realized that nodemailer seems to be a problem on workers. Is there an alternative?
3 Replies
Yakuzo
Yakuzo4mo ago
Error :
✘ [ERROR] service core:user:mail: Uncaught TypeError: globalThis.XMLHttpRequest is not a constructor

at null.<anonymous> (index.js:15931:11) in checkTypeSupport
at null.<anonymous> (index.js:15954:38) in
node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/capability.js
at null.<anonymous> (index.js:9:56) in __init
at null.<anonymous> (index.js:19358:5) in
node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/request.js
at null.<anonymous> (index.js:9:56) in __init
at null.<anonymous> (index.js:19577:5) in node-modules-polyfills:http
at null.<anonymous> (index.js:9:56) in __init
at null.<anonymous> (index.js:19698:21) in node-modules-polyfills-commonjs:http
at null.<anonymous> (index.js:12:50) in __require
at null.<anonymous> (index.js:24482:16) in node_modules/nodemailer/lib/fetch/index.js
✘ [ERROR] service core:user:mail: Uncaught TypeError: globalThis.XMLHttpRequest is not a constructor

at null.<anonymous> (index.js:15931:11) in checkTypeSupport
at null.<anonymous> (index.js:15954:38) in
node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/capability.js
at null.<anonymous> (index.js:9:56) in __init
at null.<anonymous> (index.js:19358:5) in
node_modules/rollup-plugin-node-polyfills/polyfills/http-lib/request.js
at null.<anonymous> (index.js:9:56) in __init
at null.<anonymous> (index.js:19577:5) in node-modules-polyfills:http
at null.<anonymous> (index.js:9:56) in __init
at null.<anonymous> (index.js:19698:21) in node-modules-polyfills-commonjs:http
at null.<anonymous> (index.js:12:50) in __require
at null.<anonymous> (index.js:24482:16) in node_modules/nodemailer/lib/fetch/index.js
Chaika
Chaika4mo ago
There's no way without relaying it through an external api (ex fetch a rest web server which handles the smtp part of things) Cloudflare supports TCP Egress only via through custom tcp socket stuff, not supported by many packages, and even then SMTP / 25 is blocked
Yakuzo
Yakuzo4mo ago
Okay, thanks for reply !