45

Install Postal Mail Server on Ubuntu 20.04/18.04

 3 years ago
source link: https://computingforgeeks.com/install-and-configure-postal-mail-server-on-ubuntu/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Install Postal Mail Server on Ubuntu 20.04/18.04
Search

Having a fully featured email solution is a basic requirement of any business, institution or company. Here we will discuss the installation of Postal Mail Server on Ubuntu 20.04/18.04. Postal is a mail delivery platform for both incoming and outgoing emails. It is a complete and fully featured mail server that should satisfy all your websites & web servers email requirements.

The minimum specification for Postal is as follows:

  • At least 4GB of RAM
  • At least 2 CPU cores
  • At least 100GB of disk space

Install Postal Mail Server on Ubuntu 20.04/18.04

The installation of Postal Mail Server on Ubuntu is not as complicated as others say.  By sparing some minutes and following below few steps, you should have Postal Mail Server running on Ubuntu 20.04/18.04 server.

Step 1: Update your system

Like all other installation guides available on Computingforgeeks, we start the installation by ensuring our system is updated.

sudo apt update
sudo apt -y upgrade
sudo apt -y install git jq

Step 2: Install Docker & Docker Compose

Run the command below to install Docker

wget -qO- https://get.docker.com/ | sudo bash

To run Docker as a non-privileged user, consider setting up the Docker daemon in rootless mode for your user:

dockerd-rootless-setuptool.sh install

Install Docker Compose:

Step 3: Install MySQL / MariaDB database server

The other requirement of Postal Mail server is a database server.

sudo apt install mariadb-server

Also install libmysqlclient-dev

sudo apt -y install libmysqlclient-dev

After installation of MariaDB/MySQL database server, create a user and database for Seafile.

First login to MySQL shell as root user:

$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 48
Server version: 10.3.11-MariaDB-1:10.3.11+maria~bionic-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

We will create a database for each of these server components.

CREATE DATABASE postal CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci;

Create a database user and grant privileges for created databases.

CREATE USER 'postal'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL ON postal.* TO 'postal'@'localhost';

Postal will handle the creation of databases for your mail servers but you need to give it access to do this. Allow postal user to manage all databases that are prefixed with postal-.

GRANT ALL PRIVILEGES ON `postal-%`.* to `postal`@`localhost` IDENTIFIED BY "StrongPassword";
FLUSH PRIVILEGES;
QUIT

Confirm access by Logging into the database as postal user:

$ mysql -u postal -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 49
Server version: 10.3.11-MariaDB-1:10.3.11+maria~bionic-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| postal             |
+--------------------+
4 rows in set (0.001 sec)

MariaDB [(none)]> QUIT
Bye

Step 4: Install and Configure RabbitMQ

Postal uses RabbitMQ for queueing. Install RabbitMQ on Ubuntu using the link below:

How to install Latest RabbitMQ Server on Ubuntu

You can skip the section of configuring RabbitMQ Management Dashboard and Set RabbitMQ Cluster. A single node RabbitMQ installation should be enough for small usage.

Postal requires its own RabbitMQ vhost and user to connect with. You can create these using the following commands:

sudo rabbitmqctl add_vhost postal
sudo rabbitmqctl add_user postal StrongPassword
sudo rabbitmqctl set_permissions -p postal postal ".*" ".*" ".*"

Step 5: Install and Configure Postal Mail Server on Ubuntu 20.04/18.04

Cloning the Postal repository

git clone https://postalserver.io/start/install /opt/postal/install

Create a symlink for Postal binary.

sudo ln -s /opt/postal/install/bin/postal /usr/bin/postal

Run the command below and replace postal.yourdomain.com with the actual hostname you want to access your Postal web interface at

$ sudo postal bootstrap postal.yourdomain.com
Latest version is: 2.0.0
=> Creating /opt/postal/config/postal.yml
=> Creating /opt/postal/config/Caddyfile
=> Creating signing private key
Generating RSA private key, 1024 bit long modulus (2 primes)
.....+++++
.................+++++
e is 65537 (0x010001)

This will generate three files in /opt/postal/config.

  • postal.yml is the main postal configuration file
  • signing.key is the private key used to sign various things in Postal
  • Caddyfile is the configuration for the Caddy webserver

Open Postal configuration file.

sudo vim /opt/postal/config/postal.yml

At the minimum, have the following settings:

web:
  # The host that the management interface will be available on
  host: postal.example.com
  # The protocol that requests to the management interface should happen on
  protocol: https

main_db:
  # Specify the connection details for your MySQL database
  host: localhost
  username: postal
  password: StrongPassword
  database: postal

message_db:
  # Specify the connection details for your MySQL server that will be house the
  # message databases for mail servers.
  host: localhost
  username: postal
  password: StrongPassword
  prefix: postal

rabbitmq:
  # Specify the connection details for your RabbitMQ server.
  host: 127.0.0.1
  username: postal
  password: StrongPassword
  vhost: /postal
  
dns:
  # Specifies the DNS record that you have configured. Refer to the documentation at
  # https://github.com/atech/postal/wiki/Domains-&-DNS-Configuration for further
  # information about these.
  mx_records:
    - mx.postal.example.com
  smtp_server_hostname: postal.example.com
  spf_include: spf.postal.example.com
  return_path: rp.postal.example.com
  route_domain: routes.postal.example.com
  track_domain: track.postal.example.com

smtp:
  # Specify an SMTP server that can be used to send messages from the Postal management
  # system to users. You can configure this to use a Postal mail server once the
  # your installation has been set up.
  host: 127.0.0.1
  port: 2525
  username: # Complete when Postal is running and you can
  password: # generate the credentials within the interface.
  from_name: Postal
  from_address: [email protected]

Edit the file to fit your Postal settings.

For DNS, you can use DnsMasq if you’re looking for a self-hosted simple DNS solution.

When done Initialize database by adding all the appropriate table:

$ sudo postal initialize
Pulling web      ... done
Pulling smtp     ... done
Pulling worker   ... done
Pulling cron     ... done
Pulling requeuer ... done
Creating postal_runner_run ... done
Initializing database
......
Create your initial admin user
$ sudo postal make-user
Creating postal_runner_run ... done
Postal User Creator
Enter the information required to create a new Postal user.
This tool is usually only used to create your initial admin user.

E-Mail Address      : [email protected]
First Name          : Admin
Last Name           : User
Initial Password:   : ********

User has been created with e-mail address [email protected]
Starting the application

Run the following command to start the Postal application

$ sudo postal start
Creating postal_worker_1   ... done
Creating postal_cron_1     ... done
Creating postal_smtp_1     ... done
Creating postal_requeuer_1 ... done
Creating postal_web_1      ... done

This will run a number of containers on your machine.

You can look at the status at any time using:

$ sudo postal status
      Name                     Command               State    Ports
-------------------------------------------------------------------
postal_cron_1       /docker-entrypoint.sh post ...   Up
postal_requeuer_1   /docker-entrypoint.sh post ...   Up
postal_smtp_1       /docker-entrypoint.sh post ...   Up
postal_web_1        /docker-entrypoint.sh post ...   Up
postal_worker_1     /docker-entrypoint.sh post ...   Up

Step 6: Configuring Caddy Web Server

A web proxy is required all web traffic and SSL termination. There are many options for Proxy – Nginx, Apache, HAProxy, e.t.c. In this guide we’re going to use Caddy.

We can run Caddy web server using Docker:

docker run -d \
   --name postal-caddy \
   --restart always \
   --network host \
   -v /opt/postal/config/Caddyfile:/etc/caddy/Caddyfile \
   -v /opt/postal/caddy-data:/data \
   caddy

Once this has started, Caddy will issue an SSL certificate for your domain and you’ll be able to immediately access the Postal web interface and login with the user you created in one of the previous steps.

Step 7: Access Postal Admin Web Dashboard

Access Postal Administration page on https://postal.example.com

Login with admin user email created earlier.

Refer to the Postal Administration guide for further configurations.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK