Example of OpenSSHD setup with SSL and virtual hosts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
3.1 KiB

# Before you start modifying this file, you'll want a way to debug your changes. I had
# a great deal of trouble with invalid recipients and authentication. If you run the
# server in the foreground with verbose output (-dv) and lookup traces (-T lookup)
# enabled, it will save you a hell of a lot of time: /usr/sbin/smtpd -dv -T lookup
# Load and assign certificates for your mail server. You can use the certbot certificate
# for your web domains, so long as it contains your mail server's hostname. This hostname
# needs to match the FQDN hostname of your server or container.
pki host.tld cert "/etc/ssl/cert.pem"
pki host.tld key "/etc/ssl/private/cert.key"
# The table statements below load and assign tables to names so they can be referenced as
# <table-name> in the options below:
# This file contains the passwords for your email accounts, as generated with
# smtpctl encrypt <password> (alternatively, leave the password out for stdin input)
table vpassword "/etc/smtpd/virtual/password"
# This file contains a list of your virtual domains (should not include the local domain)
table vdomain "/etc/smtpd/virtual/domain"
# This file contains a list of emails you want to route to your email accounts
table valias "/etc/smtpd/virtual/alias"
# This file contains a list of UIDs, GIDs and home directories for your email accounts
# For a virtual host setup, you would typically create a UNIX user.group like vmail.vmail
# and chown all your mailbox directories to it.
table vmailbox "/etc/smtpd/virtual/mailbox"
# Listen to the various SMTP ports, using the keys we loaded above to prove we are host.tld
listen on eth0 tls pki host.tld
listen on eth0 port 465 smtps pki host.tld auth <vpassword>
listen on eth0 port 587 tls-require pki host.tld auth <vpassword>
# These are actions that get triggered by the match rules below:
# Action to receive mail locally and send it to a maildir (~/Maildir by default but
# here we put them straight in the user's home directory as listed in <vmailbox>).
# The manpage doesn't mention it, but the order of these clauses is significant;
# you will get a syntax error if you don't follow the listing order in the manpage.
action receive maildir "%{user.directory}" userbase <vmailbox> virtual <valias>
# Action to send mail to remote SMTP server
action send relay
# Match mail from any source to your local domain (server hostname)
match from any for local action receive
# Match mail from any source to your virtual domains
match from any for domain <vdomain> action receive
# Match mail from your local network to anywhere (useful for contaners that sit on
# the same subnet and need to send email without authentication)
#match from src x.x.x.x/x for any action send
# This accepts mail from your local machine to anywhere (typical configuration)
match from local for any action send
# This accepts mail from any authenticated user to anywhere
match from any auth for any action send