3 years agoBlock more HTTP request methods master
MegaBrutal [Fri, 23 Nov 2018 23:30:30 +0000 (00:30 +0100)]
Block more HTTP request methods


modified:   Listener.pas

3 years agoUpdate todo list
MegaBrutal [Thu, 22 Nov 2018 22:15:15 +0000 (23:15 +0100)]
Update todo list

modified:   todo.txt

3 years agoAvoid memory leaks when using TRelayer
MegaBrutal [Wed, 21 Nov 2018 17:00:15 +0000 (18:00 +0100)]
Avoid memory leaks when using TRelayer

Ensure to free TTCPRFCConnection and TRelayer instance when
TRelayer.OpenConnection fails.

modified:   Relay.pas
modified:   Spool.pas

3 years ago(Relay) Minor optimization to TRelayer.OpenConnection
MegaBrutal [Wed, 21 Nov 2018 15:14:56 +0000 (16:14 +0100)]
(Relay) Minor optimization to TRelayer.OpenConnection

modified:   Relay.pas

3 years agoBind to user-specified address (BindAddress)
MegaBrutal [Tue, 20 Nov 2018 20:14:56 +0000 (21:14 +0100)]
Bind to user-specified address (BindAddress)

Bind to user-specified address for outgoing connections.

modified:   Common.pas
modified:   MgSMTP.pas
modified:   Network.pas
modified:   Relay.pas

3 years agoLog actual listen address
MegaBrutal [Mon, 12 Nov 2018 23:05:00 +0000 (00:05 +0100)]
Log actual listen address

Even if ListenAddress is a hostname, log the actual IP address the
server tries to listen on, instead of the supplied hostname.
Indicate when listen fails for any reason.

modified:   Listener.pas
modified:   MgSMTP.pas
modified:   Network.pas

3 years agoUse getaddrinfo & getnameinfo
MegaBrutal [Fri, 26 Oct 2018 15:15:55 +0000 (17:15 +0200)]
Use getaddrinfo & getnameinfo

Use getaddrinfo and getnameinfo API functions for DNS resolutions
instead of the deprecated gethostbyname and gethostbyaddr functions.

This is in preparation to IPv6 support, as getaddrinfo and getnameinfo
are agnostic to address family.

modified:   DNSResolve.pas
modified:   MgSMTP.pas
modified:   Network.pas

3 years agoFix TLogger.AddStdLine to work with Wine 1.6
MegaBrutal [Wed, 17 Oct 2018 15:30:30 +0000 (17:30 +0200)]
Fix TLogger.AddStdLine to work with Wine 1.6

Wine 1.6 gives a standard output handle to the service process,
albeit all writes to it fails. Because of this, TLogger.AddStdLine
did not even write to the log file due to short-circuit evaluation.
Now I made sure to attempt both stdout and logfile writes.

Native Windows doesn't provide an stdout handle for service processes
(GetStdHandle returns 0), in which case MgSMTP detects it has no
stdout and redirects its output to mgsmtp_stdout.log. Wine 3.0 behaves
the same, so I deemed the Wine 1.6 behaviour a bug. Therefore, I find
this quick fix sufficient - there is no need to bother with Wine 1.6
compatibility any further, e.g. by checking if Wine 1.6 gave a writable
stdout handle or not. Users of MgSMTP on Wine are rather suggested to
update to Wine 3.0.

modified:   Log.pas
modified:   MgSMTP.pas

3 years agoLog warning when deprecated ListenPort is used
MegaBrutal [Mon, 15 Oct 2018 17:00:00 +0000 (19:00 +0200)]
Log warning when deprecated ListenPort is used

Added a nice warning message to notify users to use ListenAddress
instead of ListenPort. The warning is triggered when the config has
no ListenAddress declaration, but a ListenPort setting is present.

Also replaced the slash with a backslash in the error message that
warns about missing "Server\Name" setting.

modified:   MgSMTP.pas

3 years agoListen on user-specified addresses
MegaBrutal [Fri, 12 Oct 2018 06:05:25 +0000 (08:05 +0200)]
Listen on user-specified addresses

Configuration key ListenPort has been changed to ListenAddress.
Now it is possible to supply exact addresses to listen on instead
of all addresses ( Backward compatibility is kept, so old
ListenPort values will still be interpreted (if no ListenAddress is

ListenPort = 25 ==> ListenAddress =

Multiple listen addresses may be separated by commas, e.g.
ListenAddress =,

Port 25 is implied when no port is specified for an address.

modified:   Common.pas
modified:   Listener.pas
modified:   MgSMTP.pas
modified:   Network.pas

5 years agoCatch CTRL-C event in user mode
MegaBrutal [Mon, 12 Sep 2016 20:33:12 +0000 (22:33 +0200)]
Catch CTRL-C event in user mode

modified:   MgSMTP.pas
modified:   todo.txt

5 years agoFixed a typo
MegaBrutal [Mon, 12 Sep 2016 19:20:46 +0000 (21:20 +0200)]
Fixed a typo

modified:   Relay.pas

6 years ago(Relay) Handle unexpected replies and disconnections adequately
MegaBrutal [Wed, 11 Feb 2015 23:04:50 +0000 (00:04 +0100)]
(Relay) Handle unexpected replies and disconnections adequately

- Previously it was possible that MgSMTP erroneously administered
an e-mail as delivered, when the server accepted the recipient in
the RCPT stage, but disconnected before or in the DATA stage.
This patch mainly addresses this issue, by making sure that the
transaction is completed, before administering a final status.

- MgSMTP is now more tolerant with non-compliant replies,
e.g., accepts 250 for connection opening, not only 220.

- Increased relay send buffer size from 32 lines to 64.

modified:   Common.pas
modified:   MgSMTP.pas
modified:   Relay.pas
modified:   Spool.pas

6 years agoFall back to HELO when remote server doesn't understand EHLO
MegaBrutal [Sun, 8 Feb 2015 05:35:58 +0000 (06:35 +0100)]
Fall back to HELO when remote server doesn't understand EHLO

modified:   MgSMTP.pas
modified:   Relay.pas
modified:   todo.txt

6 years agoFixed non-RFC-compliant handling of lines starting with dots
MegaBrutal [Sat, 7 Feb 2015 12:32:24 +0000 (13:32 +0100)]
Fixed non-RFC-compliant handling of lines starting with dots

MgSMTP is now compliant with the transparency guidelines
suggested in RFC 5321, section 4.5.2.

modified:   Listener.pas
modified:   MgSMTP.pas
modified:   Relay.pas
modified:   todo.txt

6 years agoOption to add Reply-To header to forwarded e-mails
MegaBrutal [Mon, 2 Feb 2015 07:28:24 +0000 (08:28 +0100)]
Option to add Reply-To header to forwarded e-mails

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

6 years agoMgSMTP 0.9s 0.9s
MegaBrutal [Mon, 15 Dec 2014 13:48:36 +0000 (14:48 +0100)]
MgSMTP 0.9s

modified:   MgSMTP.pas
modified:   todo.txt

6 years agoUpdated changelog
MegaBrutal [Sun, 14 Dec 2014 16:41:03 +0000 (17:41 +0100)]
Updated changelog

modified:   changelog.txt

6 years agoUpdated readme files
MegaBrutal [Sat, 13 Dec 2014 16:44:19 +0000 (17:44 +0100)]
Updated readme files

modified:   mgsmtp_server_example.ini
modified:   readme.txt
modified:   readme_source.txt

6 years agoUpdated sample config file to reflect new features
MegaBrutal [Thu, 11 Dec 2014 16:36:41 +0000 (17:36 +0100)]
Updated sample config file to reflect new features

Added examples, explanation for the following directives:
- PlusAliasExcept, GlobalPlusAliasExcept
- [Mailbox\@domain] sections

modified:   mgsmtp_server_example.ini

7 years agoMgSMTP 0.9s rc1
MegaBrutal [Sat, 6 Dec 2014 00:35:52 +0000 (01:35 +0100)]
MgSMTP 0.9s rc1

Improved command-line argument parsing, which will make my job easier
when I'll introduce the /CONFIG, /WORKDIR arguments. Now not
only the first argument is parsed, but all of them.

I've also edited todo.txt to reflect my vision better of further

This is Release Candidate 1.

modified:   Common.pas
modified:   MgSMTP.pas
new file:   buildall.bat
modified:   todo.txt

7 years agoInitial commit
MegaBrutal [Fri, 5 Dec 2014 15:43:54 +0000 (16:43 +0100)]
Initial commit

new file:   Bounce.pas
new file:   Common.pas
new file:   DNSMX.pas
new file:   DNSResolve.pas
new file:   EINIFiles.pas
new file:   Listener.pas
new file:   Log.pas
new file:   Mailbox.pas
new file:   MgSMTP.pas
new file:   NetRFC.pas
new file:   Network.pas
new file:   Policies.pas
new file:   RFCSMTP.pas
new file:   Relay.pas
new file:   SocketUtils.pas
new file:   Spool.pas
new file:   changelog.txt
new file:   comparewild.pas
new file:   lgpl-2.0.txt
new file:   license.txt
new file:   license_gpl-2.0.txt
new file:   license_lesser.txt
new file:   mgsmtp_server_example.ini
new file:   readme.txt
new file:   readme_source.txt
new file:   todo.txt