Skip to content

Cloudflare Workers + Route to Workers + Mailchannels => Discord

Notifications You must be signed in to change notification settings

kubectyl/cloudflare-discord-mailing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloudflare-discord-mailing

cloudflare-discord-mailing is a worker that allows you to see and respond to E-Mails in Discord using Cloudflare Workers + Route to Workers + Mailchannels.

Setup

Create a Discord application, add a bot to it in the Bot tab and invite the bot to your server.

Clone this repository and then get wrangler and the Discord developer panel ready, because we'll need to add some secrets.

  1. Deploy your worker, so we can add secrets to it. Use npm run deploy or wrangler publish.

  2. Do wrangler secret put CHANNEL_ID and enter your Discord channel that emails will be sent to. Make sure your bot has the view channels, send messages, embed links and attach files permissions!

  3. Now go to your developer panel and copy your public key. Do wrangler secret put PUBLIC_KEY and enter it.

  4. Final step is getting your bot token, by going to the Bot tab. Then reset your token to get your api token (might require 2FA). Proceed to put into wrangler with wrangler secret put TOKEN and then entering it.

  5. Now that you've done the worker setup, set your workers url as the INTERACTIONS ENDPOINT URL in the Discord General Information tab of your application. (the URL will look something like https://cloudflare-discord-mailing.<your-name>.workers.dev)

  6. Finally, go to your zone's Email Workers settings and create a custom address (or catch-all) that routes to your worker.

SPF + Mailchannels

https://mailchannels.zendesk.com/hc/en-us/articles/200262610-Set-up-SPF-Records

DKIM + Mailchannels

https://mailchannels.zendesk.com/hc/en-us/articles/7122849237389

You can use the following commands to set the required variables:

  • wrangler secret put DKIM_DOMAIN
  • wrangler secret put DKIM_SELECTOR
  • wrangler secret put DKIM_PRIVATE_KEY

Routing to multiple channels

You can modify src/routing.ts for more advanced routing.

Known limitations

  • All attachments are ignored
  • Characters past 4,096 are removed (embed description length limit)
  • Everyone can use the reply button

LICENSE

This project is using the postal-mime library which is released under the AGPL license. Due to the license, this project must also be released under AGPL.

If you find any decent email parsing library alternative that works in workers and has a more sane license, please let us know and open an issue.

About

Cloudflare Workers + Route to Workers + Mailchannels => Discord

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%