QMalcolm/SecretSanta

A simple web app for running secret santa gift exchanges

★ 0Forks 0ElixirGitHub ↗Compare

README

SecretSanta

A small Phoenix app for running a Secret Santa gift exchange from your own machine. You add participants, set who may not draw whom, make the draw, and the app emails each person the name they drew. See spec.md for the full feature specification.

Requirements

Versions are pinned in .tool-versions for asdf:

  • Erlang/OTP 28
  • Elixir 1.18

Development

mix setup        # deps, database, assets
mix phx.server   # http://localhost:4000

In development no email ever leaves the machine. Everything the app "sends" is captured at http://localhost:4000/dev/mailbox.

Before committing, run mix precommit (compile with warnings as errors, format check, unused-deps check, tests).

Running for real

Real email is only sent under prod config. The app still binds to 127.0.0.1 only; there is no authentication, so it must not be exposed beyond the machine.

Put these in a .env file in the project root (it is gitignored and loaded automatically under prod config; variables already in the environment take precedence over the file):

Variable Purpose
SECRET_KEY_BASE Generate once with mix phx.gen.secret
DATABASE_PATH Where the SQLite file lives, e.g. ~/.secret_santa/db.sqlite3
SMTP_HOST SMTP server host
SMTP_PORT SMTP server port
SMTP_USERNAME
SMTP_PASSWORD
SMTP_FROM From address on every outgoing email
SMTP_TLS always / if_available / never (default if_available)
SMTP_TLS_VERIFY peer / none (default peer)
PORT Optional, default 4000

Then:

MIX_ENV=prod mix setup
MIX_ENV=prod mix ecto.migrate
MIX_ENV=prod mix phx.server

Gmail

Gmail's SMTP server accepts app passwords only, so turn on 2-Step Verification for the account and create one at https://myaccount.google.com/apppasswords. Gmail rewrites the From header to the authenticated account, so SMTP_FROM should be the same address. Gmail's certificate is publicly trusted, so leave verification on:

SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
[email protected]
SMTP_PASSWORD=<the 16-character app password>
[email protected]
SMTP_TLS=always
SMTP_TLS_VERIFY=peer

Proton Mail

Proton has no public SMTP endpoint. Run Proton Bridge locally and point the app at it. Bridge shows its host, port, username, and password in its settings; it uses STARTTLS with a self-signed certificate, so:

SMTP_HOST=127.0.0.1
SMTP_PORT=1025
SMTP_TLS=always
SMTP_TLS_VERIFY=none

Contributors

QMalcolm

Issues