Hosting your Own Email Part 2 — GNUcode.me

Hosting your Own Email Part 2

by Joshua Branson — June 15, 2021

PROJECT My current plans for hosting email accounts

There are three basic vocab to know for setting up an email server

  • a mail transfer agent (MTA) receives and sends email (opensmtpd)
  • a mail delivery agent (MDA), which gets the email from the MTA, and stores it for a user. The easiest way is to use opensmtpd as the MDA. BUT dovecot is a better MDA, because dovecot can set up mail filtering and maybe better spam filtering.
  • Remote users can access the emails via an MUA (mail user agent), via an IMAP server. (dovecot)

My current simple strategy for hosting a few email accounts

I plan on offering paid email accounts on gnucode.me, or your own domain. So your next email could be "YourName@gnucode.me" or "wilycatperson@YourDomain.com". The following is an explanation of how it will all work together. It is intended for anyone else wanting to set up an email server for a few email accounts.

Opensmtpd is my MTA (mail transfer agent), so it sends and receives email via smtp. Also, opensmtpd uses rspamd (or bogofilter) to limit spam.

Dovecot will serve my emails. For now I will set up emails in the maildir format, because this is easy to do. Eventually, I will store email in the dbox format.

  • imap.gnucode.me will be where dovecot serves emails
  • smtp.gnucode.me will be where opensmtp sends and receives email

The simple directory structure I will use to host a few email accounts

I will have a few email accounts at gnucode.me <users>@gnucode.me. postmaster AT gnucode.me will point to my main user AT gnucode.me.

My email will be hosted at: /home/<user>/Maildir

I will tell dovecot to serve emails from the above directory via a config variable:

(dovecot-service #:config
                     (dovecot-configuration (mail-location "maildir:~/%n/Maildir")))

By default both opensmtpd and dovecot use regular login username authentication. So my username and password that I login via email is the same password that I use to login via ssh. So my email config for gnucode.me should look like this for gnus:

(nnimap "gnucode.me"
        (nnimap-stream ssl)
        (nnimap-address "imap.gnucode.me")
        (nnimap-user "joshua"))

Some difficulties

  • I login via "joshua" and <password>. I would prefer to login via joshua AT gnucode.me. That way I can distinguish joshua AT gnucode.me and joshua AT propernaming.org

  • The above explanation strategy delivers all emails to /home/joshua/Maildir, which essentially limits my total email accounts to one.

  • The above has no spam filtering or email filtering.