A nice and easy email setup on 9

Fastmail and 9front


I began to use Fastmail during fall 2020. At first, I only used one account there, but I liked it so much that I migrated accounts I hosted at Migadu there. Don’t get me wrong, I liked Migadu and I still think that it is a fine service if you receive more emails than you send. I’m receiving almost as many emails as I send, so my main email address was self-hosted on Oyabun. The whole setup was messy, and I was not happy with it. So, I migrated everything to Fastmail. The nice side effect was that it made email setup on 9front simple.

A Single Account

Since I migrated my accounts to Fastmail, I only have a single account to check. Aliases and identities are well handled by the service. With a single command, I can open a unified mailbox like my Inbox. This is the command that I have in $HOME/lib/profile.

upas/fs -f /imaps/imap.fastmail.com/roy@royniang.com
N.B. You can issue this command for any mailbox like explained here.

Where the setup really shines, though, is for sending emails. Sending emails from multiple accounts typically relies on a clunky script to determine the sending account.

#!/bin/rc
shift
smtp=tcp!smtp.fastmail.com!565
shift
dom=fastmail.com
exec /bin/upas/smtp -tu roy@royniang.com -d -a -h $dom $smtp $*
fig. Content of /mail/lib/remotemail.

Now, I just have to worry about the identity of the sender. marhsal(1) normally handle this with using the environment variable $upasname. But it is temporary and linked to a text window. A solution is to add header values to /mail/box/user/headers. The values set there will stay between sessions and text windows. I created a script to swap the From: value on the fly.

#!/bin/rc

switch($1) {
case rn
	echo 'From: roy niang <roy@royniang.com>' > /mail/box/royniang/headers
case rs
	echo 'From: something else <rs@something.info>' > /mail/box/royniang/headers
case w
	echo 'From: who knows <w@who.who>' > /mail/box/royniang/headers
case *
	echo No.
}

cat /mail/box/royniang/headers
fig. Content of $HOME/bin/rc/fml. Note that the content of the headers file is displayed in any case.

Fastmail Configuration

There is a small annoyance with how emails are handled. When you send an email, It’s not saved in your “Sent” mailbox. This is a normal behaviour, but we are in the 21st century. You can play with upas’ filters, but Fastmail have a setting to fix this problem.

From the webmail interface navigate to Settings, Sending Identities, and select your identity. In the advanced preferences, check the box for “Save a copy when sending through third party email clients”, and you are set.

You’ll notice on the remotemail script that the SMTP port is configured on the non-standard port 565. This is a small goodie that Fastmail created. When you send an email from their webmail, your IP address is stripped out of the headers, but not with a third-party client. If you use the port 565 to send your email, it will replicate this behaviour. I wonder why they didn’t add this feature with standard ports.

Links