shithub: sirjofri_de

ref: 88238de7b3307a1b02a7d2c87883be5b3a2f5539
dir: /changeblog/1594881674.ms/

View raw version
.HTML Mail Server Configuration
.TL
Mail Server Configuration
.LP
Recently I installed my mail server on 9front. Most of the time I followed the guide in the FQA, but still there are things to explain. In this document I'll go through the section of the FQA and annotate things.
.LP
Right at the beginning the FQA mentions how the executing user needs write permissions for the mailboxes. This is
.I "very important" !
If upas can't write the mailboxes the mail server will \fInot\fR accept incoming mail!
.LP
In my setup I can skip all DNS stuff, because I have my DNS hosted somewhere else. Make sure to add proper MX records as well as (at least) an SPF record.
.SH
/mail/lib/smtpd.conf
.LP
To make things short, here are the necessary lines in my setup. The server handles authenticated incoming mail for sending to other providers as well as incoming mail for local accounts.
.P1
defaultdomain    sirjofri.de
norelay          on
verifysenderdom  on
saveblockedmsg   off
ourdomains       sirjofri.de
.P2
.LP
Note that the server is no relay for unauthenticated/untrusted requests, it will still relay if you authenticate.
.LP
At this point it might be a good idea to check your user password.
Use 
.CW auth/changeuser
to add \fIInferno/POP secrets\fR to your user accounts. Use these passwords to authenticate to the smtp server.
.SH
/mail/lib/rewrite
.LP
The program that handles sending mail uses this file to rewrite mail addresses. This file is responsible for filtering out local mail as well as sending other mails to the mailer.
.LP
In my setup I added three aliases:
.P1
pOsTmAsTeR    alias postmaster
aBuSe         alias abuse
wEbMaStEr     alias webmaster
.P2
.LP
Use regular expressions to define your domain:
.P1
\\l!(.*)                alias \\1
\\l\\.sirjofri\.de!(.*)   alias \\1
sirjofri.de!(.*)       alias \\1
.P2
.LP
For translating mails I added one more rule for mail address \fItags\fR. These tags are in the form of \fIuser+tag@example.com\fR. Official specifications say that everything behind that “+” must be ignored, but it can be used to automatically sort incoming mail into folders. I do this, by the way, so I describe here, how.
.LP
We need rules for those plus signs:
.P1
\\"(.+)\\+(.*)\\"  translate "echo `{/bin/upas/aliasmail '\\1'}^'+\\2'"
# The other translate rules are default
.P2
.LP
For delivering local mails, I added extra rules:
.P1
local!(.+)\\+(.+)  |  "/bin/test -d /mail/box/\\1/\\2 \\&\\& /bin/upas/mbappend /mail/box/\\1/\\2 || /bin/upas/mbappend /mail/box/\\1/mbox"
local!"(.+)\+(.+)  |  "/bin/test -d /mail/box/\\1/\\2 \\&\\& /bin/upas/mbappend /mail/box/\\1/\\2 || /bin/upas/mbappend /mail/box/\\1/mbox"
# leave the other rules untouched.
.P2
.LP
With this settings, mails to user+\fItag\fR will be checked. If a mailbox folder for \fItag\fR exists, mail is sent to this folder. Otherwise it is sent to the user's default inbox.
.B Note:
I tested, but this \fIdoes not work\fR with aliased mail. If my aliasmail changes \fIuserA\fR to \fIuserB\fR, mails to \fIuserA+tag\fR will be rejected! If you know how I can make this work, feel free to send me a mail.
.SH
/mail/lib/names.local
.LP
This file is pretty easy. Just add your alias mail addresses:
.P1
postmaster  sirjofri
webmaster   sirjofri
abuse       sirjofri
.P2
.SH
/mail/lib/remotemail
.P1
#!/bin/rc
shift
sender=$1
shift
addr=$1
shift
fd=`{/bin/upas/aliasmail -f $sender}
switch($fd){
case *.*
    ;
case *
    fd=sirjofri.de
}
exec /bin/upas/smtp -h $fd $addr $sender $*
.P2
.SH
SMTP over TLS
.LP
I don't use port 587. I use 25 for this. Mail servers relay mails to this port by default, so it makes sense.
.LP
/rc/bin/service/tcp25
.P1
#!/bin/rc
user=`{cat /dev/user}
exec /bin/upas/smtpd -f -E -r -c /sys/lib/tls/cert -n $3
.P2
.LP
Don't forget to create your TLS certificate!
.SH
IMAP4 over TLS
.LP
I did this exactly like the FQA. See there.
.SH
No.
.LP
At this point I stopped. I did not configure ratfs and have no spam handling right now. It doesn't really matter for me, because nobody knows me and I don't use that mail address to register anywhere.
.LP
Links:
.IP →
https://fqa.9front.org/fqa7.html#7.7