Coder Social home page Coder Social logo

podop's Introduction

Podop is a piece of middleware designed to run between Postfix or Dovecot on one side, any Python implementation of a table lookup protocol on the other side.

It is thus able to forward Postfix maps and Dovecot dicts to the same (or multiple) backends in order to write a single, more flexible backend for a mail distribution.

Examples

  • Connect Postfix to a DNS lookup so that every domain that has a proper MX record to your Postfix is actually accepted as a local domain
  • Connect both Postfix and Dovecot to an HTTP microservice to run a high availability microservice-based mail service
  • Use a single database server running any Python-compatible API for both your Postfix and Dovecot servers

Configure Podop tables

Podop tables are configured through CLI arguments when running the server. You must provide a --name for the table, a --type for the table and a --param that parametrizes the map.

URL table

The URL table will initiate an HTTP GET request for read access and an HTTP POST request for write access to a table. The table is parametrized with a template URL containing § (or {}) for inserting the table key.

--name test --type url --param http://microservice/api/v1/map/tests/§

GET requests should return 200 and a JSON-encoded object that will be passed either to Postfix or Dovecot. They should return 4XX for access issues that will result in lookup miss, and 5XX for backend issues that will result in a temporary failure.

POST requests will contain a JSON-encoded object in the request body, that will be saved in the table.

Postfix usage

In order to access Podop tables from Postfix, you should setup socketmap Postfix maps. For instance, in order to access the test table on a Podop socket at /tmp/podop.socket, use the following setup:

virtual_alias_maps = socketmap:unix:/tmp/podop.socket:test

Multiple maps or identical maps can be configured for various usages.

virtual_alias_maps = socketmap:unix:/tmp/podop.socket:alias
virtual_mailbox_domains = socketmap:unix:/tmp/podop.socket:domain
virtual_mailbox_maps = socketmap:unix:/tmp/podop.socket:alias

In order to simplify the configuration, you can setup a shortcut.

podop = socketmap:unix:/tmp/podop.socket
virtual_alias_maps = ${podop}:alias
virtual_mailbox_domains = ${podop}:domain
virtual_mailbox_maps = ${podop}:alias

Dovecot usage

In order to access Podop tables from Dovecot, you should setup a proxy Dovecot dictionary. For instance, in order to access the test table on a Podop socket at /tmp/podop.socket, use the following setup:

mail_attribute_dict = proxy:/tmp/podop.socket:test

Multiple maps or identical maps can be configured for various usages.

mail_attribute_dict = proxy:/tmp/podop.socket:meta

passdb {
  driver = dict
  args = /etc/dovecot/auth.conf
}

userdb {
  driver = dict
  args = /etc/dovecot/auth.conf
}

# then in auth.conf
uri = proxy:/tmp/podop.socket:auth
iterate_disable = yes
default_pass_scheme = plain
password_key = passdb/%u
user_key = userdb/%u

Contributing

Podop is free software, open to suggestions and contributions. All components are free software and compatible with the MIT license. All the code is placed under the MIT license.

podop's People

Contributors

ghostwheel42 avatar kaiyou avatar nebukadneza avatar rakshith-ravi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

podop's Issues

Error 500 on alias lookup.

Version: 1.8
Custom setup with traefik proxy

It seems i'm getting a http 500 error on the alias lookup. This while the same e-mail can be used to login in the admin interface.
This ofcoarse causes all mail delivery to fail towards this account. The database for alias is also empty.

Mar 02 20:51:01 mail postfix/smtpd[2471]: connect from containers_traefik.1.ohh2lccbu7fs69j7c5ya48q12.containers[10.0.1.171]
ERROR:root:Error when processing request
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/podop/postfix.py", line 104, in process_request
    result = await table.get(key)
  File "/usr/lib/python3.8/site-packages/podop/table.py", line 35, in get
    raise Exception(request.status)
Exception: 500
Mar 02 20:51:01 mail postfix/smtpd[2471]: warning: socketmap:unix:/tmp/podop.socket:alias socketmap server temporary error: unknown error
Mar 02 20:51:01 mail postfix/smtpd[2471]: warning: socketmap:unix:/tmp/podop.socket:alias lookup error for "[email protected]"
Mar 02 20:51:01 mail postfix/smtpd[2471]: NOQUEUE: reject: RCPT from containers_traefik.1.ohh2lccbu7fs69j7c5ya48q12.containers[10.0.1.171]: 451 4.3.0 <[email protected]>: Temporary lookup failure; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<leibniz.yyy.yy>
Mar 02 20:51:01 mail postfix/smtpd[2471]: disconnect from containers_traefik.1.ohh2lccbu7fs69j7c5ya48q12.containers[10.0.1.171] ehlo=1 mail=1 rcpt=0/1 data=0/1 rset=1 quit=1 commands=4/6
# The alias map actually returns both aliases and local mailboxes, which is
# required for reject_unlisted_sender to work properly 
virtual_alias_domains =                                                                                                                                                                                          
virtual_alias_maps = ${podop}alias                                                                                                                                                                                
virtual_mailbox_domains = ${podop}domain                                                                                                                                                                          
virtual_mailbox_maps = ${podop}mailbox      

podop raise exception on `username@[ip]` address

Using 1.8 master docker images in kubernetes.

Testing if it's an openrelay with http://www.aupads.org/test-relay.html and whenever the address is in format username@[ip] it raise exception:

Feb 03 10:25:36 mail postfix/smtpd[281512]: warning: socketmap:unix:/tmp/podop.socket:senderaccess socketmap server temporary error: unknown error
Feb 03 10:25:36 mail postfix/smtpd[281512]: warning: socketmap:unix:/tmp/podop.socket:senderaccess lookup error for "spamtest@[x.y.z.w]"
Feb 03 10:25:36 mail postfix/smtpd[281512]: NOQUEUE: reject: RCPT from santuario.pads.ufrj.br[146.164.48.5]: 451 4.3.5 <spamtest@[206.189.154.202]>: Sender address rejected: Server configuration error; from=<spamtest@[x.y.z.w]> to=<relaytest%antispam-ufrj.pads.ufrj.br@> proto=SMTP helo=<antispam-ufrj.pads.ufrj.br>
ERROR:root:Error when processing request
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/podop/postfix.py", line 104, in process_request
    result = await table.get(key)
  File "/usr/lib/python3.8/site-packages/podop/table.py", line 35, in get
    raise Exception(request.status)
Exception: 500

Syntax errors on python 3.7

While working on Mailu/Mailu#680, in an attempt to make more common images, dovecot and postfix got upgraded to python 3.7. Upon running, I've seen the following error (same on both containers)

[tim@sky ~]$ docker logs 9c917cd8a4cc
Traceback (most recent call last):
  File "/start.py", line 12, in <module>
    from podop import run_server
  File "/usr/local/lib/python3.7/site-packages/podop/__init__.py", line 10, in <module>
    from podop import postfix, dovecot, table
  File "/usr/local/lib/python3.7/site-packages/podop/postfix.py", line 94
    return asyncio.async(self.process_request(name, key))
                       ^
SyntaxError: invalid syntax

Workaround for now is to use python 3.6 for all images.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.