Skip to content

v0.38.0

Choose a tag to compare

@cuonggt cuonggt released this 02 Oct 05:06
· 13 commits to main since this release

A development mailbox: under tug dev, with no MAIL_HOST, the mail an app sends is kept in a mailbox the app shows at /_tug/mail, each mail as a mail program would show it, where it was written out to the terminal as text alone: who it's from and to, its subject, and its text, with the link that verifies an email to copy out of the log. Its HTML, which a person's mail program shows, wasn't seen, nor its files, nor the message a mail server would take. Phoenix keeps its app's mail at /dev/mailbox, and Laravel's Sail and Herd run Mailpit beside the app: tug's mailbox needs nothing beside it.

Registering in an app made by tug new -auth, run as tug dev runs it, puts one line in its log:

mail, kept in the mailbox (MAIL_HOST isn't set): "Verify your email for blog" to ann@example.com: http://localhost:8080/_tug/mail/01M3XFRBZWEBFY0J00VADJQB31

and the mail's page has, as text, its frame of HTML aside, and its boundary cut short:

← Mailbox
Mail · Fri 2 Oct, 12:00:26
Verify your email for blog

HEADERS
To            <ann@example.com>
Subject       Verify your email for blog
Date          Fri, 02 Oct 2026 12:00:26 +0700
Message-ID    <YR2FDDMSODUU6PMX6YJEWC2CFP@localhost>
MIME-Version  1.0
Content-Type  multipart/alternative; boundary=225c68997f…

HTML
[the mail's HTML, as a mail program shows it, its button opening the link in a tab of its own]

TEXT
Hi Ann Lee,

Follow this link to verify that ann@example.com is yours, and it's where blog will reach you.

Verify my email:

http://localhost:8080/verify-email/1/tmbf8q.Cvw-CkVU76YLr9ofgz1YSA

The link works for a day. If you didn't make an account, someone typed your email by mistake: there's nothing to do.

blog

SOURCE
The message as a mail server takes it

What's new:

  • A mailbox under tug dev: with no MAIL_HOST, mail.FromEnv returns a mail.Mailbox under tug dev, which sets TUG_DEV. It keeps each mail as SMTP would send it, in .tug/mail, which git leaves out, the newest 100, and writes a line to the log for each: whom it's to, Bcc too, its subject, and its link, at APP_URL. Without TUG_DEV, as a deploy and a test run, mail is written out by Log, as before.
  • The mailbox's pages: /_tug/mail, which the App answers under Config.DevTools, before its own middleware and routes, as it does the endpoints of Inertia's DevTools: the mail, newest first, and each mail's page, with its headers, its Bcc, which no header has, its HTML, its text, its links each a link, its files, to download, and its source. They run no script, and a reload shows the mail that came since.
  • The HTML in a sandboxed frame: nothing in a mail runs, and its links open in a tab of their own, as the link that verifies an email does, into the app, in the browser the developer is logged in with.
  • mail.Mailbox: a Mailer, as Log is, for an app that makes its own: Dir, .tug/mail by default, where the App reads it; URL, the app's address, for the links; and W, the log, the standard error by default. It refuses what SMTP would, but for a mail with no From.
  • The guide: Accounts, the mail while developing, and package mail's Mailbox; CLI, what TUG_DEV turns on; Deployment, MAIL_HOST and TUG_DEV; Getting started; and the README.

Upgrading: nothing an app calls changed: go get github.com/cuonggt/tug@v0.38.0. An app that takes its mailer from mail.FromEnv, as one made by tug new -auth does, keeps its mail in the mailbox under tug dev from then on, with no change of its own, and its log has a line for each mail where it had the mail. A deploy, the app's tests, and anything run without TUG_DEV write mail out as before, and MAIL_HOST still sends it, under tug dev too, as to a Mailpit.

The guide is in docs/. tug needs Go 1.26.