DKIM signing emails from worker.

Using a worker setup like: https://developers.cloudflare.com/email-routing/email-workers/send-email-workers/ How do you add a dkim signature in a cloudflare worker mail binding? Currently cloudflare adds a DKIM-Signature with domain email.cloudflare.net, which is not aligned with my from address so all the emails from my workers land in spam. The npm packages I've tried (dkim, dkim-signer, nodemailer) all require crpyto. Though even if they required('node:crypto') I doubt they'd work. Because node:crypto does not seem to have creatSign I can't even roll my own. I don't want to use MailChannels. I don't want to be an open relay. Any suggestions?
Send emails from Workers · Cloudflare Email Routing docs
You can send an email about your Worker’s activity from your Worker to an email address verified on Email Routing. This is useful for when you want to …
1 Reply
torsten
torsten6mo ago
I've gotten a working solution now. I spun up a small rest api on my mail server that gives me the DKIM-Signature header I need to include. I fetch that include it as a header and then send off the mail. That's pretty dumb, because my mail server could have just sent the mail but it works. I now pass DMARC, SPF and DKIM for mail I'm sending myself. hurray.