# 使用mailu搭建电子邮箱

  1. https://setup.mailu.io/ 生成安装配置文件

    Version 1.9 master

    # Before starting, read the docs!

    Mailu is not perfectly documented, but still has a lot of documentation available at mailu.io (opens new window). Make sure you read the appropriate documentation for your setup and have all the requirements ready when using this wizard.

    # Step 1 - Pick a flavor

    Mailu comes in multiple "flavors". It was originally designed to run on top of Docker Compose but now offers multiple options including Docker Stack, Rancher, Kubernetes.

    Please note that "official" support, that is provided by the most active developers will mostly cover Compose and Stack, while other flavors are maintained by specific contributors.

    Compose, simply using Docker Compose manager

    Stack (DEPRECATED), using stack deployments in a Swarm cluster. Please note that next version of Mailu will not offer this flavor.

    # Step 2 - Initial configuration

    Before starting, some variables must be set.

    Mailu storage path:

    /home/docker/email

    In the following sections we need to set the postmaster address. This is a combination of the postmaster local part and the main mail domain. The main mail domain is also used as "server display name". This is the way the SMTP server identifies itself when connecting to others. The Postmaster will get an e-mail address @<main_domain>. This address will receive the DMARC "rua" and "ruf" reports. Or in plain english: if receivers start to classify your mail as spam, this postmaster will be informed.

    Main mail domain and server display name.

    mofar.top

    Postmaster local part

    admin

    Choose how you wish to handle security TLS certificates (opens new window) letsencrypt cert notls mail mail-letsencrypt

    Authentication rate limit per IP for failed login attempts or non-existing accounts

    60/ hour

    Authentication rate limit per user

    100 / day

    Outgoing message rate limit (per user)

    200/ day

    Opt-out of statistics

    Website name

    默远的邮箱

    Linked Website URL

    https://mail.mofar.top

    The admin interface is the main Mailu-specific bit, it provides tools to manage your email domains, users, etc.

    Enable the admin UI (and path to the admin UI)

    # Step 3 - Pick some features

    Mailu comes with multiple base features, including a specific admin interface, Web email clients, antispam, antivirus, etc. In this section you can enable the services to you liking.

    A Webmail is a Web interface exposing an email client. Mailu webmails are bound to the internal IMAP and SMTP server for users to access their mailbox through the Web. By exposing a complex application such as a Webmail, you should be aware of the security implications caused by such an increase of attack surface.

    Enable Web email client (and path to the Web email client)

    Enable the antivirus service An antivirus server helps fighting large scale virus spreading campaigns that leverage e-mail for initial infection. Make sure that you have at least 1GB of memory for ClamAV to load its signature database.

    Enable the webdav service A Webdav server exposes a Dav interface over HTTP so that clients can store contacts or calendars using the mail account.

    Enable fetchmail Fetchmail allows users to retrieve mail from an external mail-server via IMAP/POP3 and puts it in their inbox.

    # Step 4 - expose Mailu to the world

    A mail server must be exposed to the world to receive emails, send emails, and let users access their mailboxes. Mailu has some flexibility in the way you expose it to the world.

    Among Mailu services, the front server is the one accepting connections, be it directly from the outside world, through a reverse proxy or in any complex configuration that you might want to setup. It needs to listen on some IP addresses in order to expose its public services. You must at least setup an IPv4 or an IPv6 address if you wish to access Mailu.

    Warning You must use specific addresses, please avoid generic all-interfaces addresses like 0.0.0.0 or ::. How to find these addresses. (opens new window)

    IPv4 listen address

    103.119.28.245

    Subnet of the docker network. This should not conflict with any networks to which your system is connected. (Internal and external!)

    172.23.0.0/24

    Enable IPv6

    The unbound resolver enables Mailu to do DNSSEC verification, DNS root lookups and caching. This also helps the antispam service not to get blocked by the public or ISP DNS servers.

    Enable an internal DNS resolver (unbound)

    You server will be available under a main hostname but may expose multiple public hostnames. Every e-mail domain that points to this server must have one of the hostnames in its MX record. Hostnames must be comma-separated. If you're having trouble accessing your admin interface, make sure it is the first entry here (and possibly the same as your DOMAIN entry from earlier). Also make sure that the first entry in this list resolves to the IP address of your server, and that the reverse DNS entry for the IP address of your server resolves to this first entry in this list.

    Public hostnames

    mail.mofar.top

    # Database preferences

    Which database back end would you like to use? sqlite postgresql mysql

  2. # 生成配置

# Mailu configuration -

# Your configuration was generated

The following steps will guide you towards downloading and using your configuration files. Keep in mind that you should review every downloaded file before running anything based on it.

If you encounter issues while setting Mailu up, please review the documentation first, then check if an issue is open for that specific problem. If not, you may either use Github to open an issue and detail what your problem or bug looks like, or join us on Matrix and discuss it with contributors.

# Step 1 - Download your configuration files

Docker Compose expects a project file, named docker-compose.yml in a project directory. First create your project directory.

mkdir /home/docker/email

Then download the project file. A side configuration file makes it easier to read and check the configuration variables generated by the wizard.

cd /home/docker/email
wget https://setup.mailu.io/1.9/file/2d30347f-b1f7-49f9-881f-3e7a9a4e1687/docker-compose.yml
wget https://setup.mailu.io/1.9/file/2d30347f-b1f7-49f9-881f-3e7a9a4e1687/mailu.env

# Step 2 - Review the configuration

We did not insert any malicious code on purpose in the configurations we distribute, but your download could have been intercepted, or our wizard website could have been compromised, so make sure you check the configuration files before going any further.

When you are done checking them, check them one last time.

# Step 3 - Start the Compose project

To start your compose project, simply run the Docker Compose up command using -p mailu flag for project name.

cd /home/docker/email
docker-compose -p mailu up -d

Before you can use Mailu, you must create the primary administrator user account. This should be admin@mofar.top. Use the following command, changing PASSWORD to your liking:

docker-compose -p mailu exec admin flask mailu admin admin mofar.top PASSWORD

Login to the admin interface to change the password for a safe one, at one of the hostnames mail.mofar.top (opens new window). Also, choose the "Update password" option in the left menu.

注意事项:

  1. 修改mailu.env配置文件 WEB_ADMIN=/admin
  2. 去掉多余的端口,只保留443(https),993(imaps),465(smtps)
  1. 申请mail.mofar.top域名的tls,放到certs目录下,并分别命名为cert.pemkey.pem