smtpbridge

command module
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 2 Imported by: 0

README

SMTPBridge

GitHub GitHub tag (latest SemVer) GitHub last commit GitHub go.mod Go version Go Report Card

Bridge email to other messaging services.

Do not expose this to the Internet, this is only intended to be used on a local network.

Use Cases

  • Pictures from IP cameras
  • System messages from servers

Usage

smtpbridge

Run with database and storage in memory.

smtpbridge --memory

Restart when config file changes.

smtpbridge --watch

Config

Config file is located at ~/.smtpbridge.yml.

Starter Config

This config prints emails received via SMTP to console. The SMTP server listens on port 1025 and the HTTP server listens on port 8080. This saves emails to ~/.smtpbridge directory.

endpoints:
  - name: hello world
    type: console
Full Config
# Database
database:
  type: bolt # (bolt, memory)
  memory:
    limit: 100 # Max number of envelopes

# Storage
storage:
  type: file # (file, memory)
  memory:
    size: 104857600 # Max memory allocation in bytes, 100 MiB

# HTTP server
http:
  disable: false # (false, true)
  host: ""
  port: 8080

# SMTP server
smtp:
  disable: false # (false, true)
  host: ""
  port: 1025
  size: 26214400 # Max message size in bytes, 25 MiB
  username: ""
  password: ""

# Endpoints for envelopes
endpoints:
  - name: example endpoint
    text_disable: false
    text_template: |
      FROM: {{ .Message.From }}
      SUBJECT: {{ .Message.Subject }}
      {{ .Message.Text }}
    attachments_disable: false
    type: console
  # Console
  - name: console endpoint
    type: console
  # Telegram
  - name: telegram endpoint
    type: telegram
    config:
      token: 2222222222222222222222
      chat_id: 111111111111111111111

# Bridges to endpoints, if this is empty then envelopes will always be sent to all endpoints
bridges:
  # Send to 'console endpoint'
  - endpoints: console endpoint
  # Send to 'console endpoint' if the envelope is from 'foo@example.com' and is to 'bar@example.com'
  - from: foo@example.com
    to: bar@example.com
    endpoints: console endpoint
  # Send to all endpoints if the envelope is from 'foo@example.com' or 'baz@example.com'
  - filters:
      - from: foo@example.com
      - from: baz@example.com
  # Send to 'console endpoint' if the envelope to matches regex "@example\.com$"
  - to_regex: '@example\.com$'
    endpoints: console endpoint
  # Send to 'telegram endpoint' and 'console endpoint' if the envelope has more than 4 attachments
  - match_template: "{{ gt (len .Attachments) 4 }}"
    endpoints:
      - telegram endpoint
      - console endpoint
Template

Each template has access to the Envelope struct. See text/template on how to template.

To Do

  • Limit database and storage size
  • HTTP auth
  • Read mail files
  • Save raw emails
  • REST API
  • Windows installer

Documentation

Overview

Copyright © 2022 ItsNotGoodName

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL