sirius-press/docs/smtp.md

99 lines
3.8 KiB
Markdown
Raw Normal View History

feat(sirius-press): a WordPress where the account is a key, not a mailbox WordPress makes two assumptions this project cannot accept: that identity comes from an email address, and that a site lives at one server. Both are things somebody else can take away — a mailbox is rented from a provider who can close it or be compelled to open it, and a server is one seizure from being gone. Sirius Press replaces the first and hedges the second. Signing in means signing a challenge with the key that controls a CashAddress. The address is recovered from the signature, so nothing is typed but the signature itself, and the result is an ordinary WordPress session cookie — roles, capabilities, nonces and the REST API never learn the login was different. Three ways to produce one: a wallet the browser already exposes, a phrase used once in the page and wiped, or a signature pasted in from any BIP-137 wallet, which needs no JavaScript and lets the key stay on a machine that never touches the web. There is no password reset, and the recovery page says so plainly rather than offering a form that cannot work. A reset mechanism is by construction a way to take an account from its owner, and it is always easier to attack than the cryptography it bypasses. Publishing a post also exports it as static HTML to the name's storage on Sia, signed by the key that owns the name, so the site keeps answering when the server does not. Email as a feature is untouched. wp_mail() still works, SMTP still sends, and contact forms still deliver to addresses real people typed. Only mail to the site's own unroutable placeholder addresses is diverted to an in-app inbox. The objection was to email as identity, not to email. Core is pinned and patched rather than vendored. WordPress 7.1.1 is 149 MB and 5,008 files; the fork's entire core diff is 75 lines in wp-admin/install.php. Carrying the former to express the latter would bury the patch where nobody reviews it and make every clone of the monorepo pay for it. Upstream releases still merge through tools/update-wordpress.sh, which reapplies the series and says exactly which hunk needs a human. The cryptography is implemented twice — PHP on the server, JavaScript in the page — because the server must verify and the browser must sign. Both are pinned against libauth, the library the Sirius portal wallet and the BNS gateway already use, so a disagreement of one byte fails the test suite rather than presenting as a rejected login at three in the morning. 132 checks, no framework, about a second.
2026-09-21 01:39:38 +02:00
# Sending real email
Sirius Press does not disable `wp_mail()`. Contact forms, order receipts,
newsletters and every other reason a site has to send a human an email still
work — you just have to configure a way to send them, exactly as you would on
any WordPress site that is not running on a shared host with a mail server
already attached.
What the fork removes is email as an *identity*. What it leaves alone is email
as a *feature*. Those are different things, and conflating them is how people
end up believing the fork is more restrictive than it is.
---
## What happens without SMTP
Mail to your site's own `.invalid` placeholder addresses never reaches a mail
transport at all. It goes to the Sirius Press inbox — **Inbox** in the admin
menu — where the account holder reads it while signed in. Password-reset
attempts, comment-moderation notices and update nags all land there.
Mail to a real address is handed to PHP's `mail()`. In the Docker stack there
is no mail transport in the container, so it fails. That is the same failure
stock WordPress has in the same situation, reported the same way.
---
## Setting up SMTP
Any of the usual plugins work, because `wp_mail()` is untouched: WP Mail SMTP,
Post SMTP, FluentSMTP. Install one, point it at a provider, done.
Without a plugin, the `phpmailer_init` hook is enough:
```php
// wp-content/mu-plugins/smtp.php
add_action( 'phpmailer_init', function ( $mailer ) {
$mailer->isSMTP();
$mailer->Host = 'smtp.example.net';
$mailer->Port = 587;
$mailer->SMTPAuth = true;
$mailer->SMTPSecure = 'tls';
$mailer->Username = 'postmaster@example.net';
// Keep the secret in wp-config.php, not here, so it stays out of backups
// that include wp-content.
$mailer->Password = defined( 'SMTP_PASSWORD' ) ? SMTP_PASSWORD : '';
$mailer->From = 'hello@example.net';
$mailer->FromName = get_bloginfo( 'name' );
} );
```
A must-use plugin rather than a theme function: it should survive a theme
change, and it should not be editable from the plugin editor in wp-admin.
---
## Choosing a From address
The one thing that will not work is sending *from* a `.invalid` address. Most
providers reject it outright, and the ones that do not will have every message
binned for failing SPF.
So a site that sends mail needs one real domain, for outbound only. This is
slightly awkward for a project whose point is not depending on the DNS system,
and worth being honest about: if your site sends email, you have a dependency
on somebody's DNS, and no amount of BCNR changes that. Email is a DNS protocol.
Two ways to live with it:
- **Accept it, narrowly.** Register a domain used for nothing but outbound mail.
It has no bearing on how readers reach your site, and if it disappears you
lose contact-form delivery rather than your site.
- **Avoid sending.** Use the inbox for anything addressed to an account holder,
and for contact forms use a plugin that stores submissions in the database
and shows them in wp-admin instead of mailing them. For most small sites this
is better anyway: you read submissions where you already are, and there is no
provider to pay or be cut off by.
The second is what a Sirius Press site does by default if you never configure
anything, which is deliberate.
---
## Checking it works
Send yourself something:
```bash
wp eval 'var_dump( wp_mail( "you@example.net", "Sirius Press test", "It sends." ) );'
```
`true` means PHPMailer accepted it, not that it arrived. If it returns `true`
and nothing turns up, the problem is between your provider and the recipient —
SPF, DKIM or a spam filter — and is no longer anything to do with this fork.
To confirm the placeholder interception is working, mail one of your own
accounts. It should return `true`, nothing should leave the server, and the
message should be sitting in that account's inbox.