# Email confirmation

By default anyone can register any address, and the account exists at once. Give the server an SMTP account and it confirms the address first.

## What changes

1. The person submits their name and email. The server creates **nothing** and emails a link.
2. They open the link and press **Confirm**. Only then are the account and its key created, and the key is shown once.
3. The link works once and expires after 24 hours.

The answer to the form is the same whether or not the address already has an account, so it cannot be used to find out who is registered. An address that already has an account gets a short notice instead of a link. The same address can ask again after two minutes.

This applies to the web form, `POST /register`, `fuzzy register` and the MCP `register` tool, so an agent cannot register itself: it asks the person to confirm and hand over the key. Signing in with [GitHub or Google](self-hosting-social-login.md) never needs it, since the provider has already verified the address.

## Set it up

Use any SMTP service (a transactional provider is best, since mail from a home server is often rejected):

```text
FUZZY_SMTP_HOST=smtp.example.com
FUZZY_SMTP_PORT=587
FUZZY_SMTP_USER=...
FUZZY_SMTP_PASS=...
FUZZY_MAIL_FROM=FuzzyShare <no-reply@example.com>
```

- Port `587` upgrades to TLS with STARTTLS. Port `465` uses TLS from the start. The server will not send a password over a connection without TLS, except to the local machine.
- `FUZZY_SMTP_USER` and `FUZZY_SMTP_PASS` go together, and `FUZZY_MAIL_FROM` is required. A wrong value stops the server at start.
- Set up SPF and DKIM for the sending domain with your provider, or the mail lands in spam.
- With `FUZZY_SMTP_HOST=log` the server prints each message to its log instead of sending it. Use it only for development: the log then holds the confirmation links.

`GET /config` reports `email_confirmation: true` when it is on.

## What the emails look like

The server sends three messages, each as plain text with an HTML version in the style of the app (dark header, green accent, a button, and a dark-mode variant for clients that support it):

- **Confirm your email**: the link above.
- **Your FuzzyShare account**: the notice to an address that already has an account.
- **Welcome to FuzzyShare**: sent once when an account is created, whether by confirming an email or by signing in with GitHub or Google for the first time. It never contains the access key, which is shown once in the browser.

The messages are built by the `internal/mailkit` package, so the wording and design live in one place. The logo is `/assets/mail-logo.png` on your site's address, so set `FUZZY_PUBLIC_URL` to a public https address or the logo will not load in a mail client.

## A logo next to the sender

Mail clients show a photo next to the sender only through [BIMI](https://bimi.group). Gmail requires a DMARC policy of `p=quarantine` or `p=reject` (not `none`) and a Common Mark or Verified Mark certificate from a certificate authority that proves you own the logo. It cannot be done with DNS alone. The server serves a BIMI-ready square logo at `/assets/bimi.svg`. Once you have the certificate, publish a record like this and host the certificate (`.pem`) next to the logo:

```text
default._bimi.example.com  TXT  "v=BIMI1; l=https://example.com/assets/bimi.svg; a=https://example.com/assets/bimi.pem"
```

## Good to know

- Unconfirmed sign-ups live in the data directory for at most 24 hours and are swept after that. At most 5000 can wait at once.
- The server sends no other email: no newsletters and no marketing.
