华强北电脑城 龙岗电子世界 龙华电脑城  凯尔电脑

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1540|回复: 0

How To Install Mailu mail server on Ubuntu 20.04

[复制链接]
发表于 2022-4-4 18:03:30 | 显示全部楼层 |阅读模式

https://computingforgeeks.com/install-mailu-mail-server-on-ubuntu/


! f( O7 r7 f9 }; ?- n8 F: R) u: y

Mailu is a simple but powerful mail server running on docker containers. It is a free software open to suggestions and contributions. It is meant to provide an easy email server set up. Mailu images should run on any cloud server running Docker (>= 1.11) and you can choose between Docker compose, Kubernetes and Rancher to run your Mailu mail server. In this guide we will help users install and configure Mailu mail server on Ubuntu 20.04 Linux system.

Features of Mailu Mail server

Just like any other mail server, mailu is expected to meet the requirements of sending and receiving emails. The following are some of the most important features of Mailu mail server:


! Q4 X$ F  U. ^, u. Z/ h9 g, R7 M7 |8 }8 a% z3 h" y  D% L
  • Standard email server, IMAP and IMAP+, SMTP and Submission
  • Advanced email features, aliases, domain aliases, custom routing
  • Web access, multiple Webmails and administration interface
  • User features, aliases, auto-reply, auto-forward, fetched account
  • Admin features, global admins, announcements, per-domain delegation, quotas
  • Security, enforced TLS, Letsencrypt!, outgoing DKIM, anti-virus scanner
  • Antispam, auto-learn, greylisting, DMARC and SPF
  • Freedom, all FOSS components, no tracker included
    ) d1 V& m$ P+ I5 Q' m
Set up Mailu mail server on Ubuntu 20.04

Update your system packages before installations


( j% i6 v& b9 c& `sudo apt-get updatesudo apt-get upgrade

We need to ensure that our system has a valid IP address and a fully qualified domain name. There should also be valid mx record for our domain. To set server IP and hostname, run the below commands:

& F! W! k  T3 s; Q

5 X% q& G2 r% G0 n, U( E# b) nsudo hostnamectl set-hostname mail.example.com

Also add a server’s FQDN and IP address to /etc/hosts file.

$ sudo vim /etc/hosts62.15.116.167 mail.example.com

Once set, reboot your system


8 p! o0 f# i, W
+ H( r* }; R2 i" h% S3 u2 tsudo reboot

The following ports should be allowed through your system firewall as they are critical for emails. You can open the ports with ufw as shown below:

sudo ufw allow proto tcp from any to any port 25,80,443,110,143,465,587,993,995Install Docker and Docker compose on Ubuntu

To install docker and docker compose on Ubuntu 20.04, please check our guides on below.

Installing Docker on Ubuntu

Install Docker Compose on Ubuntu

Create Mailu Directory

After installing Docker and Docker Compose, proceed to create a directory where mailu will store its data.

sudo mkdir /mailu

Mailu uses a docker-compose.yml file and also relies on mailu.env for various settings. You need to generate a Mailu configuration for your environment using the online mailu set up utility. The generator will give you both a docker-compose.yml and a mailu.env file. Once the configuration is generated, you will receive links to use for downloading the files. Ensure that you download the files in the mailu directory. You should get a page like this when generating the files

For my installation case, I generated and got a file with the below content:


$ @2 K# G$ ?6 d$ I, L8 {( q
1 x. ~) \- j! ]! y# s* h$ vim mailu.env# Mailu main configuration file # # This file is autogenerated by the configuration management wizard for compose flavor. # For a detailed list of configuration variables, see the documentation at # https://mailu.io ################################### # Common configuration variables ################################### # Set to a randomly generated 16 bytes string SECRET_KEY=YPQAFO2THH5WSM7I # Subnet of the docker network. This should not conflict with any networks to which your system is connected. (Internal and external!) SUBNET=192.168.203.0/24 # Main mail domain DOMAIN=example.com # Hostnames for this server, separated with comas HOSTNAMES=mailu.example.com# Postmaster local part (will append the main mail domain) POSTMASTER=admin # Choose how secure connections will behave (value: letsencrypt, cert, notls, mail, mail-letsencrypt) TLS_FLAVOR=letsencrypt # Authentication rate limit (per source IP address) AUTH_RATELIMIT=10/minute;1000/hour  # Opt-out of statistics, replace with "True" to opt out DISABLE_STATISTICS=False ################################### # Optional features ################################### # Expose the admin interface (value: true, false) ADMIN=true # Choose which webmail to run if any (values: roundcube, rainloop, none) WEBMAIL=roundcube # Dav server implementation (value: radicale, none) WEBDAV=radicale # Antivirus solution (value: clamav, none) ANTIVIRUS=clamav ################################### # Mail settings ################################### # Message size limit in bytes # Default: accept messages up to 50MB # Max attachment size will be 33% smaller MESSAGE_SIZE_LIMIT=50000000 # Networks granted relay permissions # Use this with care, all hosts in this networks will be able to send mail without authentication! RELAYNETS= # Will relay all outgoing mails if configured RELAYHOST= # Fetchmail delay FETCHMAIL_DELAY=600 # Recipient delimiter, character used to delimiter localpart from custom address part RECIPIENT_DELIMITER=+

And the docker-compose file is as below:

$ docker-compose.yml# This file is auto-generated by the Mailu configuration wizard. # Please read the documentation before attempting any change. # Generated for compose flavor version: '2.2' services:  # External dependencies  redis:    image: redis:alpine    restart: always    volumes:      - "/mailu/redis:/data"      # Core services  front:    image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}nginx{MAILU_VERSION:-1.7}    restart: always    env_file: mailu.env    logging:      driver: json-file    ports:      - "62.15.116.167:80:80"      - "::1:80:80"      - "62.15.116.167:443:443"      - "::1:443:443"      - "62.15.116.167:25:25"      - "::1:25:25"      - "62.15.116.167:465:465"      - "::1:465:465"      - "62.15.116.167:587:587"      - "::1:587:587"      - "62.15.116.167:110:110"      - "::1:110:110"      - "62.15.116.167:995:995"      - "::1:995:995"      - "62.15.116.167:143:143"      - "::1:143:143"      - "62.15.116.167:993:993"      - "::1:993:993"    volumes:      - "/mailu/certs:/certs"      - "/mailu/overrides/nginx:/overrides"  admin:    image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}admin{MAILU_VERSION:-1.7}    restart: always    env_file: mailu.env    volumes:      - "/mailu/data:/data"      - "/mailu/dkim:/dkim"    depends_on:      - redis  imap:    image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}dovecot{MAILU_VERSION:-1.7}    restart: always    env_file: mailu.env    volumes:      - "/mailu/mail:/mail"      - "/mailu/overrides:/overrides"    depends_on:      - front  smtp:    image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}postfix{MAILU_VERSION:-1.7}    restart: always    env_file: mailu.env    volumes:      - "/mailu/overrides:/overrides"    depends_on:      - front  antispam:    image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}rspamd{MAILU_VERSION:-1.7}    restart: always    env_file: mailu.env    volumes:      - "/mailu/filter:/var/lib/rspamd"      - "/mailu/dkim:/dkim"      - "/mailu/overrides/rspamd:/etc/rspamd/override.d"    depends_on:      - front  # Optional services  antivirus:    image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}clamav{MAILU_VERSION:-1.7}    restart: always    env_file: mailu.env    volumes:      - "/mailu/filter:/data"  webdav:    image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}radicale{MAILU_VERSION:-1.7}    restart: always    env_file: mailu.env    volumes:      - "/mailu/dav:/data"  fetchmail:    image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}fetchmail{MAILU_VERSION:-1.7}    restart: always    env_file: mailu.env  # Webmail  webmail:    image: ${DOCKER_ORG:-mailu}/${DOCKER_PREFIX:-}roundcube{MAILU_VERSION:-1.7}    restart: always    env_file: mailu.env    volumes:      - "/mailu/webmail:/data"    depends_on:      - imap networks:  default:    driver: bridge    ipam:      driver: default      config:        - subnet: 192.168.203.0/24

When done with the settings, run mailu with docker compose as below in mailu directory

$ sudo docker-compose up -dRecreating mailu_webdav_1    ... done Recreating mailu_fetchmail_1 ... done Recreating mailu_front_1     ... done Recreating mailu_antivirus_1 ... done Recreating mailu_admin_1     ... done Recreating mailu_antispam_1  ... done Recreating mailu_imap_1      ... done Recreating mailu_smtp_1      ... done Recreating mailu_webmail_1   ... done

Set admin user by running the below command:

$ docker-compose -p mailu exec admin flask mailu admin admin example.com PASSWORDcreated admin userThis creates a user called admin@example.com with admin rights.Configure Mailu Mail Server on Ubuntu 20.04

Once done, access Mailu web portal using your hostname: https://mailu.example.com. You should get a page to login with you administrator password. Once you login, you should see a page as below. Ensure to update your password to a stronger one by clicking on ‘update password‘.

Create domains Mailu

To add a domain, click on domain→ new domain

Create users Mailu

To create users, click on Mail domains. Under manage, click on mailbox icon which takes you to user list. Click on Add user

Mailu Webmail

For my installation,I chose to use roundcube for webmail. Access webmail to start sending emails. Click on webmail which then directs you to roundcube login page.

That’s it for setting up Mailu mail server on Ubuntu 20.04. I hope it is helpful to you. Check more interesting Linux guides for your daily installations:

3 N6 k3 r9 K8 @* S. P& ]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|华强北 电脑城 龙岗电子世界 龙华电脑城 pc4g.com ( 粤ICP备16039863号 )

GMT+8, 2024-9-19 19:30 , Processed in 0.178887 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表