Skip to content

Commit

Permalink
fix: mailpit
Browse files Browse the repository at this point in the history
  • Loading branch information
xmlking committed Jun 20, 2024
1 parent 916ef57 commit 9f869e3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
29 changes: 29 additions & 0 deletions infra/base/mailpit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# mailpit

SMTP Relay for Development time.

## Mailpit TLS Certs

Generate `certs` to enable **TLS** transport for **Mailpit**, so that **hasura-auth** can use it for sending email securely.

> [!NOTE]
> we use `mailpit` for local development only. for prod env, we should use any 3rd party managed SMTP relays.
### Prerequisites

- [mkcert](https://github.com/FiloSottile/mkcert)

```shell
brew install mkcert
```

### Generate

`./create-certs.sh SAN [SAN...]` can be used for creating certificates.

```shell
cd infra/base/mailpit
./create-certs.sh mailpit
# go back to project root
cd ../../..
```
4 changes: 4 additions & 0 deletions infra/base/mailpit/certs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
30 changes: 30 additions & 0 deletions infra/base/mailpit/create-certs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail
set -o errtrace

PRODUCT=mailpit
if [[ "$#" -lt 1 ]]; then
echo "Usage: $0 SAN [SAN...]"
echo
echo "Example: $0 mailpit"
echo
echo "The following files will be created under ./certs"
echo "- certs/{ca.pem,cert.pem,key.pem}"
echo "- SAN"
exit 1
fi
if ! command -v mkcert >/dev/null; then
echo "Missing mkcert (https://github.com/FiloSottile/mkcert)"
exit 1
fi
SAN=$@

(
mkdir -p certs
CAROOT=$(pwd) mkcert -cert-file certs/tls.crt -key-file certs/tls.key ${SAN} >/dev/null 2>&1
cp -f rootCA.pem certs/ca.pem
rm -f rootCA.pem rootCA-key.pem
)

0 comments on commit 9f869e3

Please sign in to comment.