### Install Dependencies with Bun Source: https://github.com/riskymh/emailthing/blob/main/apps/pwa/README.md Installs project dependencies using the Bun package manager in the root directory. ```sh bun install ``` -------------------------------- ### Run Development Environment with Bun Source: https://github.com/riskymh/emailthing/blob/main/apps/api/README.md Starts the development server for the API. This command should be executed within the 'api' directory of the project. ```sh bun dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/riskymh/emailthing/blob/main/apps/web/README.md Installs project dependencies using the Bun package manager. This command should be run in the root directory of the project. ```sh # in root directory bun install ``` -------------------------------- ### Run Development Environment Source: https://github.com/riskymh/emailthing/blob/main/apps/web/README.md Commands to set up the database and run the Next.js development server. `bun db:push` deploys the database schema, and `bun dev --turbo` starts the Next.js application with turbo mode enabled. ```sh # in root directory bun db:push # in web directory bun dev --turbo ``` -------------------------------- ### Run Development Environment with Bun Source: https://github.com/riskymh/emailthing/blob/main/apps/pwa/README.md Starts the development server for the PWA application in the 'pwa' directory. ```sh bun dev ``` -------------------------------- ### Install Dependencies with Bun Source: https://github.com/riskymh/emailthing/blob/main/apps/api/README.md Installs project dependencies using Bun, the package manager for the monorepo. This command should be run in the root directory of the project. ```sh bun install ``` -------------------------------- ### Send Basic Email with SDK Source: https://github.com/riskymh/emailthing/blob/main/packages/emailthing/README.md Shows a basic example of sending an email using the EmailThing SDK. It includes the 'from', 'to', 'subject', and 'text' fields. ```javascript await emailthing.send({ from: 'you@example.com', to: ['user@gmail.com'], subject: 'hello world', text: 'it works!', }); ``` -------------------------------- ### Send Email Endpoint Source: https://github.com/riskymh/emailthing/blob/main/apps/web/app/api/v0/README.md API endpoint for sending emails using a mailbox alias. Supports various fields like 'to', 'cc', 'bcc', 'reply_to', 'from', 'subject', 'html', 'text', and custom 'headers'. Includes examples for full and minimal requests, and possible responses. ```APIDOC POST /api/v0/send Send an email with an mailbox alias. JSON Body: | Key | Value | Description | | --------------------- | ----------- | -------------------------------------- | | `to` | `string[]` | Recipient email address. | | `cc` | `string[]?` | Cc recipient email address. | | `bcc` | `string[]?` | Bcc recipient email address. | | `reply_to` | `string?` | Reply-to email address. | | `from` | `string` | Sender email address. | | `subject` | `string` | Email subject. | | `html` | `string?` | The HTML version of the message. | | `text` | `string?` | The plain text version of the message. | | `headers` | `object?` | Custom headers to add to the email. | Example: ```json { "to": [ "RiskyMH@riskymh.dev", "EmailThing " ], "bcc": [ "verysecret@mydomain.com" ], "reply_to": "no-reply@emailthing.xyz", "from": "You know who ", "subject": "Hello, World!", "text": "Hello, World!", "html": "

Hello, World!

", "headers": { "X-Entity-Ref-ID": "23456789", }, "config": { // no config options right now } } // minimal: { "to": ["RiskyMH@riskymh.dev"], "from": "RiskyMH@emailthing.xyz", "subject": "Hello, World!", "text": "Hello, World!", } ``` Response (200) ```json { "success": true, } ``` Response (400) ```json { "error": "Invalid email address" } ``` ``` -------------------------------- ### Receiving Emails Worker Setup Source: https://github.com/riskymh/emailthing/blob/main/cloudflare-workers/README.md This Cloudflare Worker receives emails sent to a custom domain. It forwards the raw email body to a front-end application using the fetch API. Configuration requires an 'auth' environment variable and optionally a 'forward' variable for email forwarding. For self-hosting with a default domain, 'zone' and 'internal' query parameters are needed. ```javascript // receiving-emails.js // This worker receives emails and sends the raw body to the front-end app. // Requires 'auth' environment variable. // Optional 'forward' environment variable for forwarding emails. // For self-hosting default domain: add 'zone' and 'internal' query parameters to the route. ``` -------------------------------- ### Initialize EmailThing SDK Source: https://github.com/riskymh/emailthing/blob/main/packages/emailthing/README.md Demonstrates how to import and initialize the EmailThing JavaScript SDK with an API key. This is the first step to using the SDK for sending emails. ```javascript import { EmailThing } from 'emailthing'; const emailthing = new EmailThing('et__aaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbb'); ``` -------------------------------- ### Build Production App with Bun Source: https://github.com/riskymh/emailthing/blob/main/apps/pwa/README.md Builds the production-ready static HTML files for the PWA, outputting them to the 'dist' directory. ```sh bun build ``` -------------------------------- ### Environment Variables Configuration Source: https://github.com/riskymh/emailthing/blob/main/apps/web/README.md Lists the required environment variables for local development and their descriptions. These are crucial for setting up the database connection, application URL, notification keys, email sending credentials, and S3 storage. ```APIDOC Environment Variables: DATABASE_URL: Description: The connection string for the postgres DB Required: Yes NEXT_PUBLIC_APP_URL: Description: The URL where the app is hosted Required: No NEXT_PUBLIC_NOTIFICATIONS_PUBLIC_KEY: Description: The public key for sending notifications Required: Yes WEB_NOTIFICATIONS_PRIVATE_KEY: Description: The private key for sending notifications Required: Yes EMAIL_AUTH_TOKEN: Description: The secret key for sending through cloudflare worker Required: Yes EMAIL_DKIM_PRIVATE_KEY: Description: The DKIM private key Required: No S3_KEY_ID: Description: The Access Key ID for S3 Required: Yes S3_SECRET_ACCESS_KEY: Description: The Secret Access Key for S3 Required: Yes S3_URL: Description: The Client URL for S3 Required: Yes ``` -------------------------------- ### Project Structure Overview Source: https://github.com/riskymh/emailthing/blob/main/README.md Provides a high-level overview of the project's applications, including their technologies and current development status. It highlights the transition from the original Next.js web app to the new React PWA and Bun API. ```Markdown

Next.js Logo
Web (original)


The original web app that was made with Next.js.

This is right now whats used in production, however the others are being focused on and this soon will just be here as deprecated and historic value.

React.js Logo
PWA (in progress)


The PWA app that was made with React & Bun bundler. This is a complete rewrite of the web app.

Try it out.

Next.js Logo
API (in progress)


The API that was made with Bun's Bun.serve. This is a complete rewrite of the web app (api section).
``` -------------------------------- ### API (Bun) Source: https://github.com/riskymh/emailthing/blob/main/README.md The API component built with Bun, utilizing `Bun.serve`. This API is a rewrite of the web application's API section and is currently in progress. It will handle email sending, receiving, and syncing operations. ```Bun

Next.js Logo
API (in progress)


The API that was made with Bun's Bun.serve. This is a complete rewrite of the web app (api section). ``` -------------------------------- ### Send Advanced Email with SDK Source: https://github.com/riskymh/emailthing/blob/main/packages/emailthing/README.md Illustrates sending a more complex email using the EmailThing SDK, including CC, BCC, reply-to, HTML content, and custom headers. This showcases the full capabilities for email composition. ```javascript await emailthing.send({ from: 'Me ', to: [ 'Friend ' ], cc: ['Me '], bcc: ['Me '], reply_to: 'Everyone ', subject: 'hello world', text: 'it works!', html: '

it works!

', headers: { 'X-Entity-Ref-ID': '23456789', }, config: { // no config options right now }, }); ``` -------------------------------- ### Run EmailThing CLI Source: https://github.com/riskymh/emailthing/blob/main/packages/emailthing/README.md Provides the command to execute the EmailThing CLI tool from the terminal. This is used for interacting with the EmailThing service via the command line. ```bash $ bunx emailthing ``` -------------------------------- ### PWA App (React) Source: https://github.com/riskymh/emailthing/blob/main/README.md A Progressive Web App (PWA) developed using React and the Bun bundler. This application represents a complete rewrite of the web app's functionality and is currently under development. It aims to provide an improved user experience. ```React

React.js Logo
PWA (in progress)


The PWA app that was made with React & Bun bundler. This is a complete rewrite of the web app.

Try it out. ``` -------------------------------- ### Create Admin User Script Source: https://github.com/riskymh/emailthing/blob/main/apps/web/README.md A TypeScript script used to create an admin user after the database has been set up. This script is essential for initial user management and subsequent user invitations via the `/api/invite` endpoint. ```typescript scripts/create-admin.ts ``` -------------------------------- ### Web App (Next.js) Source: https://github.com/riskymh/emailthing/blob/main/README.md The original web application built with Next.js. It is currently in production but is slated for deprecation in favor of the PWA and API components. ```Next.js

Next.js Logo
Web (original)


The original web app that was made with Next.js.

This is right now whats used in production, however the others are being focused on and this soon will just be here as deprecated and historic value.

``` -------------------------------- ### Robot Exclusion Protocol Rules Source: https://github.com/riskymh/emailthing/blob/main/apps/web/app/robots.txt Defines the rules for web crawlers accessing the emailthing project. It specifies which directories and pages are disallowed or allowed. ```robots.txt User-agent: * Disallow: /mail Allow: / Allow: /home ``` -------------------------------- ### Robot Exclusion Protocol Rules Source: https://github.com/riskymh/emailthing/blob/main/apps/pwa/public/robots.txt Defines the rules for web crawlers accessing the emailthing project. It specifies which directories and pages are disallowed or allowed. ```robots.txt User-agent: * Disallow: /mail Allow: / Allow: /home ``` -------------------------------- ### EmailThing API Headers Source: https://github.com/riskymh/emailthing/blob/main/apps/web/app/api/v0/README.md Defines the required headers for all EmailThing API requests, including Authorization and Content-Type. ```APIDOC Headers: The headers all routes use and require. | Header | Type | Description | | --------------- | -------- | ------------------------------------------- | | `Authorization` | `string` | The token to use, (eg `Bearer et__abcd...`) | | `Content-Type` | `string` | Currently only supports `application/json` | ``` -------------------------------- ### MailChannels Transactional API Source: https://github.com/riskymh/emailthing/blob/main/cloudflare-workers/README.md Documentation reference for the MailChannels Transactional API used for sending emails via the 'sending-emails.js' Cloudflare Worker. Provides details on how to send emails through their service. ```APIDOC MailChannels Transactional API: Endpoint: https://api.mailchannels.net/tx/v1 Method: POST Headers: Content-Type: application/json Authorization: Bearer YOUR_API_KEY Body: personalizations: Array of recipients and their settings. to: Array of recipient email addresses. subject: Email subject. from: Sender's email address. content: Array of content objects. type: 'text/plain' or 'text/html'. value: Email body content. Example Request: { "personalizations": [ { "to": [ { "email": "recipient@example.com" } ], "subject": "Hello from EmailThing!" } ], "from": { "email": "sender@yourdomain.com" }, "content": [ { "type": "text/plain", "value": "This is the email body." } ] } ``` -------------------------------- ### Receive Email Endpoint Source: https://github.com/riskymh/emailthing/blob/main/apps/web/app/api/v0/README.md API endpoint for receiving emails, primarily used for custom domains and Cloudflare Email Workers. It accepts 'to', 'from', and raw 'email' content in the JSON body. ```APIDOC POST /api/v0/receive-email Sending your emails to the front-end app. Mainly for custom domains and cloudflare email workers. JSON Body: | Key | Value | Description | | ------- | -------- | ------------------------------------------ | | `to` | `string` | The email address the email was sent to. | | `from` | `string` | The email address the email was sent from. | | `email` | `string` | The raw email content. | Example: ```json { "to": "RiskyMH@riskymh.dev", "from": "RiskyMH@emailthing.xyz", "email": "Date: Mon, 1 Apr 2025 01:00:00 +0000 From: RiskyMH Subject: Hello, World! To: Content-Type: text/plain Hello, World!" } ``` ``` -------------------------------- ### Sending Emails Worker (MailChannels Proxy) Source: https://github.com/riskymh/emailthing/blob/main/cloudflare-workers/README.md This worker acts as a proxy to send emails via the MailChannels API. It is intended for self-hosting scenarios and is currently non-functional, left for documentation purposes. It requires an 'auth' environment variable matching the front-end app's EMAIL_AUTH_TOKEN. It leverages Cloudflare Workers' free tier for sending emails. ```javascript // sending-emails.js // WARNING: This no longer works and is only left for documentation purposes. // Only needed if you are selfhosting EmailThing. // Proxies emails to MailChannels API. // Requires 'auth' environment variable (same as EMAIL_AUTH_TOKEN in front-end). // Refer to https://api.mailchannels.net/tx/v1/documentation for MailChannels API details. ``` -------------------------------- ### Whoami Endpoint Source: https://github.com/riskymh/emailthing/blob/main/apps/web/app/api/v0/README.md API endpoint to retrieve information about the current token. Returns the 'mailboxId' upon successful authentication. ```APIDOC GET /api/v0/whoami Get the current token's information. Response (200) ```json { "mailboxId": "somerandomid", } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.