MattMckenzy / Mail2Gotify

Simple stand-alone service that hosts an STMP server, receives mail and redirects them to a Gotify instance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mail2Gotify

Simple stand-alone service that hosts an STMP server, receives mail and redirects them to a Gotify instance.

Description

This application will let you redirect mail to your gotify instance. It can help aggregate notifications from services or systems that don't support Gotify.

Usage

Simply fill up the necessary configuration variables, host the service and expose the configured port.

TLS1.1 or 1.2 is mandatory and Mail2Gotify will need an X502 certificate to function. You can choose to point the "CertLocation" variable to a valid *.pfx certificate, provided by Let's Encrypt for example, or leave it empty to have Mail2Gotify cerate a self-signed one. Keep in mind, however, that self-signed certificates might not be accepted by certain applications, such as pfSense's notifications service.

Create a Gotify Application if necessary and point your email notifier to the host and port, using the Gotify App name as the authentication user and the Gotify App token as the authentication password. You can also append a dash and priority number to the application name, i.e. "pfSense-6", to change the priority level of the Gotify notification. Default priority is 5.

Configuration

Configuring the service is done either the appsettings.json found at "/Mail2Gotify", or with associated environment variables (great for docker). Here's a list and small description of available configuration variables:

Variable Default Description
Logging:LogLevel:Default Debug Default .NET logging level.
Logging:LogLevel:Microsoft Warning Default .NET Microsoft logging level.
Logging:LogLevel:Microsoft.Hosting.Lifetime Information Default .NET Microsoft Hosting logging level.
Services:Gotify:ServiceUri Gotify's service uri.
Services:Gotify:Header X-Gotify-Key Gotify's authentication header to use (the default is typically correct).
Services:Mail2Gotify:HostAddress The address on which this service resides.
Services:Mail2Gotify:HostPort 587 The port that this service will use to receive mail through SMTP.
Services:Mail2Gotify:CacheDirectory The directory to use for persistent caaching (bind with docker for permanency).
Services:Mail2Gotify:CertLocation The location for the X502 certificate used for TLS encryption. If left empty, Mail2Gotify will create a self-signed certificate with the variables below.
Services:Certificate:Name Mail2Gotify The name used for the creation of the X502 certificate used for the SMTP server's TLS encryption.
Services:Certificate:Password The password used for the creation of the X502 certificate.

Docker

Here's how I configure my installation :

docker-compose.yaml

version: "3"

volumes:
  cache:

services:
  mail2gotify:
    container_name: mail2gotify
    entrypoint:
      - dotnet
      - Mail2Gotify.dll
    environment:
      - Services:Mail2Gotify:HostAddress=localhost
      - Services:Mail2Gotify:CacheDirectory=/app/cache
      - Services:Mail2Gotify:CertLocation=/app/certs/privkey.pfx      
      - Services:Gotify:ServiceUri=https://gotify.exampledomain.ca
      - TZ=America/Toronto
    image: mattmckenzy/mail2gotify:latest      
    volumes:
      - cache:/app/cache
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - /mnt/docker/storage/volumes/swag_data/_data/etc/letsencrypt/live/exampledomain.ca:/app/certs
    restart: always
    ports:
      - "587:587"
    network_mode: "host"

Donate

If you appreciate my work and feel like helping me realize other projects, you can donate at https://paypal.me/MattMckenzy!

About

Simple stand-alone service that hosts an STMP server, receives mail and redirects them to a Gotify instance.

License:GNU General Public License v3.0


Languages

Language:C# 94.6%Language:Shell 4.4%Language:Dockerfile 1.0%