Option to add Reply-To header to forwarded e-mails
authorMegaBrutal <code+git@megabrutal.com>
Mon, 2 Feb 2015 07:28:24 +0000 (08:28 +0100)
committerMegaBrutal <code+git@megabrutal.com>
Mon, 2 Feb 2015 07:28:24 +0000 (08:28 +0100)
modified:   Common.pas
modified:   Mailbox.pas
modified:   MgSMTP.pas
modified:   mgsmtp_server_example.ini
modified:   todo.txt

Common.pas
Mailbox.pas
MgSMTP.pas
mgsmtp_server_example.ini
todo.txt

index 7260c08594d73897068976fad21e7b192cdde076..8e0b7fb443ffa93db0871a7522e42a007bbc40f6 100644 (file)
@@ -1,5 +1,5 @@
 {
-   Copyright (C) 2010-2014 MegaBrutal
+   Copyright (C) 2010-2015 MegaBrutal
 
    This unit is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -173,7 +173,7 @@ type
 const
 
    { MgSMTP version: }
-   VERSION_STR       = '0.9s';
+   VERSION_STR       = '0.9t';
 
    { Architecture: }
 {$IFDEF CPU64}
index b600a2aa74e07c63ebc89f11c5b297b701d26f80..3fc2020f81ce50932c089ef74fbc518b8bcc7564 100644 (file)
@@ -1,6 +1,6 @@
 {
    MegaBrutal's SMTP Server (MgSMTP)
-   Copyright (C) 2010-2014 MegaBrutal
+   Copyright (C) 2010-2015 MegaBrutal
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
@@ -90,6 +90,7 @@ type
       ForwardToList: TStringList;
       SpoolObject: TSpoolObjectCreator;
       OrigSpoolID: string;
+      FReplyTo: string;
       FForwardHeaders, FRemail: boolean;
    public
       function CheckQuota(MailSize: longint): boolean; override;
@@ -98,6 +99,7 @@ type
       function FinishDeliverMessage(LockID: longint): boolean; override;
       function Lock: longint; override;
       function Release(LockID: longint): boolean; override;
+      property ReplyTo: string read FReplyTo;
       property ForwardHeaders: boolean read FForwardHeaders;
       property Remail: boolean read FRemail;
    end;
@@ -198,6 +200,7 @@ begin
    inherited Create(Name, Domain, Config, Slave, DefaultQuota);
    Self.PhysicalMailbox:= PhysicalMailbox;
 
+   FReplyTo:= GetMailboxConfig(Config, Name, Domain, 'ReplyTo', '');
    FForwardHeaders:= GetMailboxConfig(Config, Name, Domain, 'ForwardHeaders', true);
    FRemail:= GetMailboxConfig(Config, Name, Domain, 'Remail', false);
 
@@ -516,6 +519,13 @@ begin
             Headers.Insert(0, 'X-Forwarded-To: ' + ForwardToList.DelimitedText);
          end;
 
+         if ReplyTo <> '' then begin
+            if ReplyTo = '!' then
+               Headers.Insert(0, 'Reply-To: <' + Recipient + '>')
+            else
+               Headers.Insert(0, 'Reply-To: ' + ReplyTo);
+         end;
+
          SpoolObject.Open;
          for i:= 0 to Headers.Count - 1 do
             SpoolObject.DeliverMessagePart(Headers.Strings[i]);
index e0ee6364e9f71b1306f8205790ca5370c011e9b3..808a90ddaafe2298f6f22dc280e56f78a742c9f9 100644 (file)
@@ -1,6 +1,6 @@
 {
    MegaBrutal's SMTP Server (MgSMTP)
-   Copyright (C) 2010-2014 MegaBrutal
+   Copyright (C) 2010-2015 MegaBrutal
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
@@ -49,7 +49,7 @@ const
      document what bugfix/feature are you testing with the actual build.
      This will be logged to help you differentiate outputs of subsequent
      builds in your logs. If left empty, it won't be added to the logs. }
-   DEVCOMMENT  =  '';
+   DEVCOMMENT  =  'New feature to add "Reply-To" to forwarded messages';
 
 var
 
@@ -308,7 +308,7 @@ begin
             Out.writeln('Trying to contact Service Control Manager...');
             Out.writeln('(If you see this message on console, you tried to');
             Out.writeln('start up the program incorrectly. Your current');
-            Out.writeln('attempt will fail, or it may hang under Wine.');
+            Out.writeln('attempt will fail, or it may hang under Wine.)');
             Out.writeln;
             ServiceMode:= true;
             if not StartServiceCtrlDispatcher(ServiceTable) then begin
index 258e2c03e79b72c8178315b92bd514ef01a6267b..f414a68b5794a2bdac4e45425cf945d9ee89a1ac 100644 (file)
@@ -1,5 +1,5 @@
 ; MegaBrutal's SMTP Server (MgSMTP)
-; Copyright (C) 2010-2014 MegaBrutal
+; Copyright (C) 2010-2015 MegaBrutal
 
 ; This is an example configuration file for MgSMTP.
 ; You may inspect it to learn about the configuration options of MgSMTP, and (if
@@ -657,6 +657,22 @@ StoreLocalCopy = On
 ; (You can still have "StoreLocalCopy" off, if you don't want your message to be
 ; actually delivered to the mailbox.)
 
+; Reply addresses and simple distribution lists:
+; As the following example shows, with the combination of "ForwardTo" and "ReplyTo",
+; it is possible to create simple, static distribution lists, where replies are
+; addressed back to the distribution list by default.
+; The value of "ReplyTo" will be inserted as a "Reply-To" header to the e-mails being
+; forwarded. Note, it will only affect forwarded e-mails: the local copy won't have
+; the "Reply-To" header.
+; There is a special value for "ReplyTo": "!". When used, it will be substituted with
+; the appropriate mailbox address (in this example, it is "party@example.com").
+
+;[Mailbox\party]
+;ForwardTo = benga@example.com,hugo@example.com,kitty@example.com
+;ReplyTo = Party Unit <party@example.com>
+; Or:
+;ReplyTo = !
+
 ; Domain-specific mailboxes:
 
 ;[Mailbox\@mydomain.tld]
index 209b244379e334f1a285d6f4312962cf0c0c40d8..7a59bc3cc0d2f690a5c7039560cc1bf678df1873 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -25,6 +25,7 @@ v0.9t:
 - Process CTRL-C properly to quit from user mode gracefully
 - IPv6
 - Bind to user-specified IPs
++ Option to add Reply-To header to forwarded e-mails
 
 v0.9s:
 + Change "Client disconnected, and thread exited successfully." to "Client disconnected."