Christof Meerwald@exim_mailalias.notes | |||||
Exim mailalias/announceSometimes it's useful to be able to set up outgoing mail aliases to send out announcements or reach a limited group of people -- similar to a closed majordomo or mailman mailing list. But if only need a really cut down version just to send the odd announcement and you don't fancy installing any additional software just for that purpose, you might just do it with Exim. The version I am using is fairly easy to set up and uses SQLite for the member management. > Exim Main Configuration Settings domainlist mailalias_domains = sqlite;/etc/mail/mailalias.db \ SELECT DISTINCT domain FROM forward \ WHERE domain='${quote_sqlite:${domain}}' domainlist local_domains = +mailalias_domains : \ +user_domains The local_domains shown here is just an example an will differ from your local configuration -- you just need to make sure to add +mailalias_domains to the local_domains domainlist. > Exim mailalias Router mailalias: debug_print = "R: mailalias for $local_part@$domain" driver = redirect domains = +mailalias_domains no_check_local_user senders = ${lookup sqlite {/etc/mail/mailalias.db \ SELECT sender FROM sender \ WHERE local_part='${quote_sqlite:${local_part}}' \ AND domain='${quote_sqlite:${domain}}'}} condition = ${if and {\ {or {{match_ip{$sender_host_address}{+relay_from_hosts}} \ {!eq{$authenticated_id}{}}}} \ {!match{$header_x-loop-detect:}{^<${local_part}@${rxquote:${domain}}>\$}}}} headers_add = "X-Loop-Detect: <${local_part}@${domain}>" data = ${lookup sqlite {/etc/mail/mailalias.db \ SELECT recipient FROM forward \ WHERE local_part='${quote_sqlite:${local_part}}' \ AND domain='${quote_sqlite:${domain}}'}} forbid_file forbid_include forbid_pipe retry_use_local_part mailalias_fail: driver = redirect domains = +mailalias_domains data = ":fail: ${if match{$header_x-loop-detect:}{^<${local_part}@${rxquote:${domain}}>\$} \ {Mail loop detected}{Invalid address}}" allow_fail no_more Note that the condition in the mailalias router is very restrictive to avoid any forged posts to the mailing list from the outside (but you might want to adapt that to your local requirements). And finally, we need to set up the database to actually create our announcement mailing lists. > Database Schema for /etc/mail/mailalias.db CREATE TABLE forward (id INTEGER PRIMARY KEY, local_part TEXT NOT NULL, domain TEXT NOT NULL, recipient TEXT NOT NULL); CREATE TABLE sender (id INTEGER PRIMARY KEY, local_part TEXT NOT NULL, domain TEXT NOT NULL, sender TEXT NOT NULL); CREATE INDEX forward_address ON forward (local_part, domain); CREATE INDEX forward_domain ON forward (domain); CREATE INDEX sender_address ON forward (local_part, domain); To create a test@announce.example.com mailing list we can then use the following SQL statements to populate the database. > Sample /etc/mail/mailalias.db INSERT INTO forward (local_part, domain, recipient) VALUES ('test', 'announce.example.com', 'user1@example.com'); INSERT INTO forward (local_part, domain, recipient) VALUES ('test', 'announce.example.com', 'user2@example.com'); INSERT INTO sender (local_part, domain, sender) VALUES ('test', 'announce.example.com', 'sender@example.com'); | |||||
This Web page is licensed under the Creative Commons Attribution - NonCommercial - Share Alike License. Any use is subject to the Privacy Policy.
Revision: 1.2, cmeerw.org/notes/exim_mailalias.html Last modified: Mon Sep 03 18:20:51 2018 |
Christof Meerwald <cmeerw@cmeerw.org> XMPP: cmeerw@cmeerw.org |