Git Product home page Git Product logo

rsfa's Introduction

Mailcow RSFA

RSFA is short for recipient specific from address. It provides a custom modification of (mainly) mailcow's postfix setup to support usage of recipient specific from (or sender) addresses.

What is this being used for?

To impede credential stuffing attacks (actually your mail users should be smart enough to not use the same password on multiple sites, but who knows...) and to facilitate monitoring of usage or leakage of e-mail addresses when signing up to foreign services, some people consider it being smart to utilize service specific e-mail addresses for account registration.

With a "normal" mailcow installation, this can be typically be achieved by leveraging the plus-extension scheme:

Plus Extension Addressing

Just use user+extension@domain.tld instead of user@domain.tld as your e-mail address and you are all set. Mailcow can be configured how the plus extension should be handled - I prefer rewriting of the subject line by adding a [extension] tag over direct delivery to a folder named extension.

However, there's a second solution for service specific e-mail addresses: subdomain addressing

Subdomain Addressing

Subdomain addressing provides an additional subdomain for every configured user. That subdomain is then being configured as catch-all and every incoming e-mail will be delivered to the respective user's mailbox:

Any mail sent to arbitrary-string@user.domain.tld will be delivered to user@domain.tld.

Problem

Both addressing schemes shown above do exactly what we'd expect. However, there's one pitfall:

Whenever you receive an e-mail to such an address and want to reply to it, the response would be sent from your mail account and your actual e-mail address would be used as sender address instead of the recipient/service specific one.

This could be circumvented by using an MUA that allows rewriting of the respective header lines, but this is cumbersome and not even possible on many MUAs, especially on your mobile devices.

Solution

Let your mail system do the work for you:

Every incoming mail addressed to either a plus-extension address or a subdomain address will be processed to reflect information on the original To-address in the mail's subject line as follows:

Original recipient address Original Subject Subject after processing
user+extension@domain.tld The quick brown fox jumps over the lazy dog [extension] The quick brown fox jumps over the lazy dog
extension@user.domain.tld The quick brown fox jumps over the lazy dog |extension@user| The quick brown fox jumps over the lazy dog

Whenever you reply to such an e-mail (or even write a new mail having respective tags in the subject line), the postfix submission service (well, actually the cleanup service that is triggered from submission) will apply a filter to these messages and

  • Remove the tag from the subject line
  • Rewrite the header from address accordingly
  • Validate sender permissions for subdomain addressing
  • Remove already calculated DKIM signatures
  • Reinject the message for delivery

Effectively, this will yield the following result:

Original sender address Original Subject Subject after processing Sender address after processing
[email protected] [extension] The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog user+extension@domain.tld
[email protected] |extension@user| The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog extension@user.domain.tld

The position of the tag within the subject line doesn't play any role, it might occur anywhere.


Setup

Download RSFA

Check out this repository to your mailcow:dockerized installation directory (the directory where mailcow.conf can be found) on your docker host.

Enable Plus Extension

  1. Login to mailcow UI as mailbox user
  2. Navigate to Mailbox->Settings
  3. Define "In Subject" as tagged mail handling routine:
    Screenshot Mailcow UI

Configure Subdomain Addressing

Just execute the script SDA_setup.sh from the RSFA folder on your docker host.
This will:

  • retrieve all mailbox names from all domains

  • create a new subdomain "mailboxname.domain" for each domain with dots (".") in mailbox names being translated to dashes ("-"), e.g.:
    Mailboxes:

    Created subdomains:

    • joe.domain.tld
    • john-doe.domain.tld
  • create a catch-all alias for the newly created subdomain, pointing to the respective mailbox, e.g.:
    @john-doe.domain.tld -> [email protected]

  • create a sender ACL to allow mailbox to send as *@subdomain

  • copy the DKIM configuration of each subdomain to all of its newly created subdomains

Afterwards you still have to add respective MX (and DKIM / SPF) records to your DNS; check the DNS settings for each of your subdomains in mailcow UI for advice.

Install RSFA

Execute install.sh from the RSFA folder on your docker host.


DISCLAIMER

This project had been derived from a manual setup I've applied to my own mail system over time. You might use it as is, but please be aware that this is far beyond production grade code quality. Use at your own risk!

rsfa's People

Contributors

xofolowski avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.