Setting up Mailrise with Docker

I recently discovered Mailrise, which is an SMTP gateway for Apprise notifications. You can use Mailrise to have devices that only use SMTP for notifications or alerts, and Mailrise will convert it to one of the many supported notifications found here.

In this post, I will be configuring it with Signal. To deploy Mailrise with Signal, I will be using an LXC container on a Proxmox server running Debian (I am using a template I created that has docker preinstalled. Instructions to install it can be found here).

A brief overview of what we need to do is found below.

  • Deploy the Signal REST-API docker image found here. You can find the setup instructions on the apprise documentation page found here.
  • Link your Signal account to the Signal REST- API docker image.
  • Generate a mailrise.conf file.
  • Deploy Mailrise with docker-compose

Signal

First, make a directory that will hold the docker-compose files. I will be using the /opt/docker directory. You will need elevated privileges to create the directory if you are not running as root.

sudo mkdir -p /opt/docker/signal-rest-api/
sudo runs the command as root and the -p flag makes sure that any missing parent directories in the specified path are created.
  • If you are not running as root, you will need to change the ownership of the /opt/docker/ folder. You can do this by using sudo chown -R <user>:<user> /opt/docker/. Change the <user> to your username.
You can run this with docker as shown in the Getting Started page of the project's README here. I prefer to use docker-compose as I can see the configuration that I used to deploy the container.

Next, create the docker-compose.yml file for the Signal REST-API docker image.

nano /opt/docker/signal-rest-api/docker-compose.yml
version: '3'

services:
  signal-api:
    image: bbernhard/signal-cli-rest-api
    container_name: signal-api
    restart: always
    environment:
      MODE: native
    ports:
      - 8080:8080
    volumes:
      - ./signal-cli:/home/.local/share/signal-cli
Contents of /opt/docker/signal-rest-api/docker-compose.yml

Bring up the container by running the docker-compose -f /opt/docker/signal-rest-api/docker-compose.yml up -d (Or docker-compose up -d if you're in the directory where the docker-compose.yml file is located).

Register your Signal number by going to http://10.0.69.1:8080/v1/qrcodelink?device_name=signal-api. Replace 10.0.69.1 with the IP address of your machine. You can link your number by going to the Signal app > Settings > Linked Devices.

Mailrise

To deploy Mailrise, make a directory in the /opt/docker directory.

mkdir /opt/docker/mailrise
You shouldn't need to use sudo as the folder's owner shoudl be your current user (or you're running as root).

Then create the docker-compose.yml file in the /opt/docker/mailrise directory using nano.

version: '3'

services:
  mailrise:
    container_name: mailrise
    image: yoryan/mailrise
    restart: unless-stopped
    ports:
      - 8025:8025
    volumes:
      - ./mailrise.conf:/etc/mailrise.conf
Contents of /opt/docker/mailrise/docker-compose.yml.

Before deploying the container, you will need to create the mailrise.conf file. The docker-compose.yml file sets the location of the mailrise.conf file in the same directory as indicated by the ./ in the last line of the configuration file.

Note: If you don't create the file, a directory will be created when the container is deployed. You'll need to remove the folder and create the file.
nano /opt/docker/mailrise/mailrise.conf
configs:
# The following line will be the email username for the email destination address.
# Because it is set as signal, the email address to be used is signal@mailrise.xyz
  signal:
    urls:
    # The following will send a Signal "Note to Self".
      - signal://10.0.69.1:8080/18001234567
    # The following will send a signal message to the second number in the URL.
      - signal://10.0.69.1:8080/18001234567/18007654321
    # You can leave both lines to receive a "Note to Self" and send the message to the specified number as well.
# In the line below, the email username is set to jamesjonahjameson, so the email recipient will be jamesjonahjameson@mailrise.xyz
  jamesjonahjameson:
    urls:
      - signal://10.0.69.1:8080/18001234567/15557654321
Contents of /opt/docker/mailrise/mailrise.conf.
Note: Modify the signal:// lines to reflect your IP address and Signal recipient and destination phone number. You can also choose if you want to send a message to yourself or to another Signal number.

In the mailrise.conf file shown above, there is a section for signal and another section called jamesjonahjameson. These can be used to have different email recipients so that when you send an email to signal@mailrise.xyz, you get a signal Note to Self. When you send an email to jamesjonahjameson@mailrise.xyz, someone else gets notified.

There are several urls you can add to the config file, such as Microsoft Teams, PagerDuty, Home Assistant, Mastodon, PushBullet, Pushover, and so many more. You can find a list of all the supported notification services here.

After you configure the mailrise.conf file, bring up the container with docker-compose -f /opt/docker/mailrise/docker-compose.yml up -d (Or docker-compose up -d if you're in the directory where the docker-compose.yml file is located).

Verifying installation

You can verify the docker containers are running by executing docker ps.

Output of docker ps on my instance.
Note: If you have any errors running a container, you can check the logs by running docker logs <container_name> -f. You can also run docker-compose logs -f if you are in the directory where the docker-compose.yml file is at.

An example of the directory structure can be found below (You can run tree /opt/docker/ to check your file structure).

[user@fedora ~]# tree /opt/docker/
.
├── mailrise
│   ├── docker-compose.yml
│   └── mailrise.conf
└── signal-api
    ├── docker-compose.yml
    └── signal-cli

Using Mailrise

There are several ways you can use Mailrise to send notifications.

Linux

In Linux, you can use ssmtp to create an email from the command line.

After installing ssmtp, modify the /etc/ssmtp/ssmtp.conf file to have the following

mailhub=10.0.69.1:8025
UseTLS=NO
UseSTARTTLS=NO
FromLineOverride=YES
FromLineSender=YES
Contents of /etc/ssmtp/ssmtp.conf.

Now that the configuration for ssmtp is done, you can send a message by executing the following:

echo "Current Directory is $(pwd)" | ssmtp signal@mailrise.xyz

A more useful example command can be found below.

{
    echo To: signal@mailrise.xyz
    echo From: from_email@example.com
    echo Subject: Current user is $USER
    echo "Body Message goes here"
    echo "You can add more info here such as the IP address"
    echo "Public IP is :" $(curl ifconfig.co)
    echo "Private IP is $(ip addr show eth0 | grep 'inet\b' | awk '{print $2}' | cut -d '/' -f1)"
} | ssmtp signal@mailrise.xyz

Windows (PowerShell)

In Windows, you can use the Send-MailMessage PowerShell cmdlet (more info found here). You can add variables to receive some information about the system as well.

Send-MailMessage -From "admin@$env:COMPUTERNAME.local" -To "signal@mailrise.xyz" -Subject "subject" -Body  "Machine running $env:PROCESSOR_ARCHITECTURE" -SmtpServer 10.0.69.1 -Port 8025