Mailrise is an SMTP server that converts the emails it receives into Apprise notifications

Overview

Mailrise logo

mailrise

An SMTP gateway for Apprise notifications.

Description

Mailrise is an SMTP server that converts the emails it receives into Apprise notifications. The intended use case is as an email relay for a home lab or network. By accepting ordinary email, Mailrise enables Linux servers, Internet of Things devices, surveillance systems, and outdated software to gain access to the full suite of 60+ notification services supported by Apprise, from Matrix to Nextcloud to your desktop or mobile device.

Just as email brought written messages into the 21st century, Mailrise brings email notifications into the year 2021 and beyond. Compared to a conventional SMTP server, it's more secure, too—no more replicating your Gmail password to each of your Linux boxes!

A Mailrise daemon is configured with a list of Apprise configuration files. Email senders encode the name of the desired configuration file into the recipient address. Mailrise then constructs the resulting Apprise notification(s) using the selected configuration.

A minimalist Mailrise configuration, for example, might contain a single Apprise configuration for Pushover:

configs:
  pushover:
    urls:
      - pover://[...]

And email senders would be able to select this configuration by using the recipient address:

[email protected]

It is also possible to specify one of the four Apprise notification types:

[email protected]

Email attachments will also pass through to Apprise if the addressed notification service(s) support attachments.

Mailrise is the sucessor to SMTP Translator, a previous project of mine that articulated a similar concept but was designed solely for Pushover.

Installation

As a Docker container

An official Docker image is available from Docker Hub. To use it, you must bind mount a configuration file to /etc/mailrise.conf.

From PyPI

You can find Mailrise on PyPI.

Once installed, you should write a configuration file and then configure Mailrise to run as a service. Here is the suggested systemd unit file:

[Unit]
Description=Mailrise SMTP notification relay

[Service]
ExecStart=/usr/local/bin/mailrise /etc/mailrise.conf

[Install]
WantedBy=multi-user.target

From source

This repository is structured like any other Python package. To install it in editable mode for development or debugging purposes, use:

pip install -e .

To build a wheel, use:

tox -e build

Configuration

The mailrise program accepts a path to a YAML configuration file that encapsulates the daemon's entire configuration. The root node of this file should be a dictionary. Mailrise accepts the following keys (periods denote sub-dictionaries):

Key Type Value
configs dictionary

Contains the Apprise configurations. The key is the name of the configuration and the value is the YAML configuration itself, exactly as it would be specified in a standalone file for Apprise.

The configuration name must not contain a period.

listen.host string

Specifies the network address to listen on.

Defaults to all interfaces.

listen.port number

Specifies the network port to listen on.

Defaults to 8025.

tls.mode string

Selects the operating mode for TLS encryption. Must be off, onconnect, starttls, or starttlsrequire.

Defaults to off.

tls.certfile string If TLS is enabled, specifies the path to the certificate chain file. This file must be unencrypted and in PEM format.
tls.keyfile string If TLS is enabled, specifies the path to the key file. This file must be unencrypted and in PEM format.
smtp.hostname string

Specifies the hostname used when responding to the EHLO command.

Defaults to the system FQDN.

Note

This project has been set up using PyScaffold 4.0.2. For details and usage information on PyScaffold see https://pyscaffold.org/.

Comments
  • TLS disables authentication

    TLS disables authentication

    Config:

    configs:
      pushover:
        urls:
          - pover://xxxxxxxxxxxxxxxx@yyyyyyyyyyyyyyyyy
    tls:
      mode: starttls
      certfile: /etc/ssl/cert.pem
      keyfile: /etc/ssl/key.pem
    smtp:
      hostname: nxdomain.info
      auth:
        basic:
          pushover: xxxxxxxxxxxxxxxxxxx
    

    msmtp:

    <-- 220 nxdomain.info Mailrise 0.0.post1.dev1+g8928d73
    --> EHLO localhost
    <-- 250-nxdomain.info
    <-- 250-SIZE 33554432
    <-- 250-8BITMIME
    <-- 250-SMTPUTF8
    <-- 250-STARTTLS
    <-- 250 HELP
    --> QUIT
    <-- 221 Bye
    msmtp: the server does not support authentication
    

    Observation: 250-AUTH LOGIN PLAIN is missing

    Log:

    [2022-12-20 16:34:36] ERROR:asyncio:Fatal error: protocol.data_received() call failed.
    protocol: <asyncio.sslproto.SSLProtocol object at 0x7f5392c1b710>
    transport: <_SelectorSocketTransport fd=10 read=polling write=<idle, bufsize=0>>
    Traceback (most recent call last):
      File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 1009, in _read_ready__data_received
        self._protocol.data_received(data)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'SSLProtocol' object has no attribute 'data_received'
    [2022-12-20 16:34:36] ERROR:mail.log:('172.18.0.1', 37216) SMTP session exception
    Traceback (most recent call last):
      File "/home/mailrise/.local/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 895, in smtp_STARTTLS
        await waiter
      File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 1009, in _read_ready__data_received
        self._protocol.data_received(data)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    AttributeError: 'SSLProtocol' object has no attribute 'data_received'
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/home/mailrise/.local/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 728, in _handle_client
        await method(arg)
      File "/home/mailrise/.local/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 899, in smtp_STARTTLS
        raise TLSSetupException() from error
    aiosmtpd.smtp.TLSSetupException
    

    Steps to reproduce:

    I generated a self-signed certifcate, changed the owner to the mailrise container user and mounted it:

    openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 3650 -nodes -subj '/CN=nxdomain.info'
    sudo chown 999:999 *.pem
    
      mailrise:
        container_name: mailrise
        image: yoryan/mailrise
        restart: always
        volumes:
          - ./mailrise.conf:/etc/mailrise.conf
          - ./cert.pem:/etc/ssl/cert.pem
          - ./key.pem:/etc/ssl/key.pem
    
    question 
    opened by bt90 9
  • Feature request - enable smtp auth

    Feature request - enable smtp auth

    I would like to see a way to use some kind of authentication when you send emails to the mailrise. At least some type of local username/password list in the configuration file or maybe even a LDAP(S) integration if it can be implemented easily.

    I know that this is meant to be used in a private network where there shouldn't be unauthorised access, but I still would want to use authentication.

    enhancement 
    opened by kaislaoja 6
  • Feature Request- Configuration File example

    Feature Request- Configuration File example

    Since I'm a relative noob to writing config files for docker containers it would be nice to have an example of /etc/mailrise.conf to work from. So I could cut down some different errors of syntax, etc... Thanks for making such a great project!

    documentation 
    opened by bigjdunham 6
  • Features to consider

    Features to consider

    First off, this can't be merged as is because the CI script will fail (it's pointing to this fork's package repo) -- but I still wanted to get this here for you to consider. Here are the changes in this fork:

    • Docker image size reduced from 919MB to 58.9MB for amd64
    • Made dockerfile compatible with arm64, arm32
    • Github Actions to automatically build & publish a multiplatform image for amd64/arm64/arm32
    • Removed the hardcoded mailrise.xyz domain from destination addresses
      • If the config key appears to have a domain, e.g. [email protected], it will just use that address
      • If the config key does not have a domain, e.g. phil, then the default domain is appended resulting in something like [email protected]
      • Added a config entry for default_domain that is set to mailrise.xyz when omitted to be consistent with the previous behavior
    opened by philproctor 6
  • SMTP session exception - KeyError: 'multipart/related'

    SMTP session exception - KeyError: 'multipart/related'

    Great project, thanks for your work!

    I'm experiencing an issue when I'm trying to use mailrise as an SMTP->Telegram gateway. I'd like mailrise to forward emails with attached images from my security cameras to a Telegram group conversation. I'm using Blue Iris as an NVR software and mailrise is running on the same machine as BI on windows x64 with Python 3.9.7.

    configs:
      telegram:
        urls:
          - tgram://BOTID/CHATID/?image=Yes
    

    When sending an email I'm experiencing the following error:

    [2021-09-02 22:42:41] INFO:mailrise.skeleton:Loaded configuration with 1 recipient(s)
    [2021-09-02 22:42:41] INFO:mail.log:Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin)
    [2021-09-02 22:42:41] INFO:mail.log:Peer: ('::1', 62137, 0, 0)
    [2021-09-02 22:42:41] INFO:mail.log:('::1', 62137, 0, 0) handling connection
    [2021-09-02 22:42:41] INFO:mail.log:('::1', 62137, 0, 0) EOF received
    [2021-09-02 22:42:41] INFO:mail.log:('::1', 62137, 0, 0) Connection lost during _handle_client()
    [2021-09-02 22:42:41] INFO:mail.log:('::1', 62137, 0, 0) connection lost
    [2021-09-02 22:42:46] INFO:mail.log:Available AUTH mechanisms: LOGIN(builtin) PLAIN(builtin)
    [2021-09-02 22:42:46] INFO:mail.log:Peer: ('127.0.0.1', 62141)
    [2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) handling connection
    [2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) >> b'HELO nvr.local'
    [2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) >> b'MAIL FROM:<blueiris@nvr>'
    [2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) sender: blueiris@nvr
    [2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) >> b'RCPT TO:<[email protected]>'
    [2021-09-02 22:42:46] INFO:mailrise.skeleton:Accepted recipient: [email protected]
    [2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) recip: [email protected]
    [2021-09-02 22:42:46] INFO:mail.log:('127.0.0.1', 62141) >> b'DATA'
    [2021-09-02 22:42:47] ERROR:mail.log:('127.0.0.1', 62141) SMTP session exception
    Traceback (most recent call last):
      File "C:\Python39\lib\site-packages\aiosmtpd\smtp.py", line 728, in _handle_client
        await method(arg)
      File "C:\Python39\lib\site-packages\aiosmtpd\smtp.py", line 1438, in smtp_DATA
        status = await self._call_handler_hook('DATA')
      File "C:\Python39\lib\site-packages\aiosmtpd\smtp.py", line 465, in _call_handler_hook
        status = await hook(self, self.session, self.envelope, *args)
      File "C:\Python39\lib\site-packages\mailrise\smtp.py", line 113, in handle_DATA
        notification = parsemessage(message)
      File "C:\Python39\lib\site-packages\mailrise\smtp.py", line 200, in parsemessage
        body = body_part.get_content().strip()
      File "C:\Python39\lib\email\message.py", line 1096, in get_content
        return content_manager.get_content(self, *args, **kw)
      File "C:\Python39\lib\email\contentmanager.py", line 25, in get_content
        raise KeyError(content_type)
    KeyError: 'multipart/related'
    [2021-09-02 22:42:47] INFO:mail.log:('127.0.0.1', 62141) EOF received
    [2021-09-02 22:42:47] INFO:mail.log:('127.0.0.1', 62141) Connection lost during _handle_client()
    [2021-09-02 22:42:47] INFO:mail.log:('127.0.0.1', 62141) connection lost
    

    Any help would be appreciated.

    bug 
    opened by janost 5
  • Publish images to GHCR

    Publish images to GHCR

    Dockerhub has a rate limit of 100 pulls/6 hours and is continuing to make decisions that aren't on the best interest to FOSS. It would be great if you could push the docker image to GHCR as well. It should only be a few extra lines in your workflow file. Thanks!

    opened by onedr0p 4
  • libpython3.10.so.1.0: cannot open shared object file

    libpython3.10.so.1.0: cannot open shared object file

    I have deployed your docker and I am seeing the below error

    /usr/local/bin/python: error while loading shared libraries: libpython3.10.so.1.0: cannot open shared object file: No such file or directory

    opened by ithakaa 4
  • Filtering options

    Filtering options

    Hi, really great project!

    I have some applications which sends HTML encoded mails to mailrise. Sadly matrix is not able to output the content correct. So I get some random gibbish in the notification.

    Would it be possible to only pass through the subject of the mail? Most of the informations are in there so it's okay when i don't get the body of the message. I think this solution is way easier then removing the HTML content.

    enhancement 
    opened by murmelbahn 4
  • Handle docker signals

    Handle docker signals

    Judging by the ~10s it takes to restart the container, the Mailrise process is not handling the incoming SIGTERM signal.

    https://docs.docker.com/compose/faq/#why-do-my-services-take-10-seconds-to-recreate-or-stop

    https://docs.python.org/3/library/signal.html

    enhancement 
    opened by bt90 3
  • docs: add self-signed example

    docs: add self-signed example

    Borrowed the openssl command from https://aiosmtpd.readthedocs.io/en/latest/smtp.html#enabling-starttls and added an explanation on how to properly mount it in the container.

    opened by bt90 3
  • Advertise auth support in EHLO

    Advertise auth support in EHLO

    I'm basically hitting the problem described here:

    https://marlam.de/msmtp/old-mailinglist/msg00533.html

    I've configured mailrise to use basic authentication but msmtp fails to send mails.

    EHLO as reported by msmtp -v:

    <-- 220 a4360929b762 Mailrise 0.0.post1.dev1+gbf98187
    --> EHLO localhost
    <-- 250-a4360929b762
    <-- 250-SIZE 33554432
    <-- 250-8BITMIME
    <-- 250-SMTPUTF8
    <-- 250 HELP
    --> QUIT
    <-- 221 Bye
    msmtp: the server does not support authentication
    msmtp: could not send mail (account mailrise from /etc/msmtprc)
    

    According to the msmtp devs the mailserver should report this as part of its EHLO.

    Btw the Readme is a bit confusing. The example seems to be missing the auth key.

    Readme:

    smtp:
      basic:
        username: password
        AzureDiamond: hunter2
    

    Correct config according to https://github.com/YoRyan/mailrise#configuration

    smtp:
      auth:
        basic:
          username: password
    
    bug 
    opened by bt90 3
Owner
Ryan Young
Polyglot programmer-writer and citizen of the Internet.
Ryan Young
Churn Emails Inbox - Churn Emails Inbox Using Python

Churn Emails Inbox In this project, I have used the Python programming langauge

null 2 Nov 13, 2022
Envia-emails - A Python Program that creates emails

Envia-emails Os emails é algo muito importante e usado. Pensando nisso, eu criei

José Rodolfo 2 Mar 5, 2022
Tempmail API aswell as a SMTP server.

Tempmail API/Server Tempmail API aswell as a SMTP server. Website · Report Bug · Request Feature Setup Firstly create a mongodb account, and proceed t

femboy.party 16 Mar 9, 2022
A SMTP server for use as a pytest fixture that implements encryption and authentication.

SMTPDFix: Test email, locally A simple SMTP server based on aiosmtpd for use as a fixture with pytest that supports encryption and authentication. All

James Warne 11 Sep 3, 2022
This python script will generate passwords for your emails, With certain lengths, And saves them into plain text files.

How to use. Change the Default length of genereated password in default.length.txt Type the email for your account. Type the website that the email an

null 2 Dec 26, 2021
:incoming_envelope: IMAP/SMTP sync system with modern APIs

Nylas Sync Engine The Nylas Sync Engine provides a RESTful API on top of a powerful email sync platform, making it easy to build apps on top of email.

Nylas 3.5k Dec 23, 2022
Esio_dev 3 Oct 15, 2021
xxnx its a simple smtp tool for mails spaming

xxnx its a simple smtp tool for mails spaming what is smpt? Simple Mail Transfer Protocol or smtp service. The Simple Mail Transfer Protocol (SMTP) is

0xD4$H 3 Feb 27, 2022
Command line interface for sending email using SMTP (ships with Gmail configuration).

mailsend Description Lightweight command line interface for sending email using SMTP. Default configuration is set for Gmail (smtp.gmail.com at port 5

Keith Mathe 1 Mar 22, 2022
SMTP In some vulnerable configurations, email servers can also be aggregated Use information that gives us information about the host or network Give

SMTP In some vulnerable configurations, email servers can also be aggregated Use information that gives us information about the host or network Give. The SMTP protocol supports some basic commands such as VRFY and EXPN Slowly A VRFY request asks the server to verify an email address while Which requests an EXPN request for email list membership. These requests are The power is sometimes misused to verify the existence of a user on the email server Used by hackers later

m3hr44n 1 Jan 16, 2022
Django SMTP Protocol with Gmail

Django SMTP Protocol with Gmail This is the free service from gmail to send and receive emails. What we need for this things done, Python/pip install

Mehedi Hasan 3 Dec 13, 2022
Python script for imap, pop3, smtp and IPv4 analyze

Python script for imap, pop3, smtp and IPv4 analyze

Vladislav Kotletkin 1 Jan 30, 2022
A script based on an article I wrote on decluttering emails.

Decluttering_Email A script based on an article I wrote on decluttering emails. What does this program do? This program is a python script that sends

Ogheneyoma Obomate Okobiah 6 Oct 21, 2021
Heimdall watchtower automatically sends you emails to notify you of the latest progress of your deep learning programs.

This software automatically sends you emails to notify you of the latest progress of your deep learning programs.

Zhenyue Qin 22 Dec 6, 2021
Send Emails through the terminal , fast and secure

Send Emails through the terminal , fast and secure

null 11 Aug 7, 2022
Django module to easily send emails/sms/tts/push using django templates stored on database and managed through the Django Admin

Django-Db-Mailer Documentation available at Read the Docs. What's that Django module to easily send emails/push/sms/tts using django templates stored

LPgenerator 250 Dec 21, 2022
Use Django admin to manage drip campaign emails using querysets on Django's User model.

Django Drip Drip campaigns are pre-written sets of emails sent to customers or prospects over time. Django Drips lets you use the admin to manage drip

Zapier 630 Nov 16, 2022
PGP encrypted / multipart templated emails for Django

Created by Stephen McDonald Introduction django-email-extras is a Django reusable app providing the ability to send PGP encrypted and multipart emails

stephenmcd 75 May 14, 2022
Django module to easily send templated emails using django templates, or using a transactional mail provider (mailchimp, silverpop, etc.)

Django-Templated-Email Info: A Django oriented templated email sending class Author: Bradley Whittington (http://github.com/bradwhittington, http://tw

Vinta Software 659 Dec 27, 2022