24 Commits

Author SHA1 Message Date
Timmy Welch
8e9ea901e9 Merge remote-tracking branch 'gh/main' 2025-12-12 01:49:12 -08:00
Alberto Bertogli
24c2c4f5fd Make the max queue size and give up time configurable
Today, the maximum number of items in the queue, as well as how long we
keep attempting to send each item, is hard-coded and not changed by end
users.

While they are totally adequate for chasquid's main use cases, it can
still be useful for some users to change them.

So this patch adds two new configuration options for those settings.
They're marked experimental for now, so we can adjust them if needed
after they get more exposure.

Thanks to Lewis Ross-Jones <lewis_r_j@hotmail.com> for suggesting this
improvement, and help with testing it.
2025-06-07 11:00:00 +01:00
Alberto Bertogli
8ded1f6f5e Auto-format protobuf files
This patch runs clang-format on the protobuf files, and also adds a
Makefile target for auto-formatting code (Go and protobuf) for
convenience.
2023-10-03 23:34:23 +01:00
Alberto Bertogli
fa1db7d81a config: Support "" values for drop_characters and suffix_separators
If the `drop_characters` or `suffix_separators` options are set to "",
currently instead of the empty string, their default value is used instead.

This is a bug, and it also happens on other config options, but because
the others have to be set in order for chasquid to function, it's not a
problem in practice.

Thanks Björn Busse (bbusse@github) for finding and reporting this
problem, on irc and in https://github.com/albertito/chasquid/issues/25.

This patch fixes the problem by marking these fields explicitly
optional, which enables presence testing, as described in the protobuf
documentation:
https://github.com/protocolbuffers/protobuf/blob/master/docs/field_presence.md.
2022-01-21 12:07:34 +00:00
lordwelch
660da4a85b Allow multiple authentications for the same relay based on from domain
Allow dovecot auth paths to use tcp
Add any domains of authenticated users to localDomains
2021-01-29 14:19:19 -08:00
lordwelch
e685366a28 Add support for sending mail to a specific relay
Update go-cmp and protobuf
Add support for dovecot auth over tcp
2021-01-24 13:27:07 -08:00
Alberto Bertogli
e79586a014 Implement HAProxy protocol support
This patch implements support for incoming connections wrapped in the
HAProxy protocol v1.

This is useful when running chasquid behind a HAProxy server, as it
needs the original source IP to perform SPF checks.

This patch is a reimplementation of one originally provided by Denys
Vitali in pull request #15, except the logic for the protocol handling
is moved to a new package, and the smtpsrv.Conn handling of the source
IP is simplified.

It is marked as experimental for now, since we want to give it a bit
more exposure just in case the option/api needs adjustment.

Thanks a lot to Denys Vitali (@denysvitali in github) for sending the
original patch for this, and helping test it!
2020-11-13 20:49:42 +00:00
Alberto Bertogli
d9d56552f3 maillog: Support logging to stdout and stderr
This patch adds support for writing maillog to stdout and stderr, which
can be desirable in certain environments.

Thanks to Denys Vitali <denys@denv.it> who sent an alternative patch for
this functionality.
2020-05-24 02:26:18 +01:00
Alberto Bertogli
50986a7b7e Update protobuf library to v2
There is a new protobuf library (and corresponding code generator) for
Go: google.golang.org/protobuf.

It is fairly compatible with the previous v1 API
(github.com/golang/protobuf), but there are some changes.

This patch adjusts the code and generated files to the new API.

The on-wire/on-disk format remains unchanged so this should be
transparent to the users.
2020-05-16 10:12:51 +01:00
Alberto Bertogli
13ee3ba482 courier: Use the hostname in SMTP HELO
The SMTP courier, which handles outgoing connections, uses the domain of
the envelope's from as the domain in the HELO/EHLO greeting.

This works fine in practice, but ideally the domain used in the greeting
should match the reverse DNS record. This used to be more relevant but
nowadays it is not really enforced; however, it sometimes comes up in
self checks, and might cause some confusion when troubleshooting.

So this patch makes it use the configured hostname instead, which is
under the users' control and more likely to be compliant. It also
simplifies the code.

The documentation of the hostname configuration option is also updated
to mention this behaviour.

Thanks to Jonas Seydel (thor77) for bringing this up.
2020-05-13 20:27:17 +01:00
Alberto Bertogli
17b7bbe9c6 dovecot: Remove "experimental" qualifiers
dovecot support has been around for a release, has decent testing and
seems stable enough to remove the "experimental" qualifier.
2018-06-04 23:45:18 +01:00
Alberto Bertogli
d39d3aaff4 chasquid: Dovecot support (experimental)
This patch adds dovecot support to the chasquid daemon, using the
internal dovecot library added in previous patches.

Dovecot support is still considered EXPERIMENTAL and may be reverted, or
changed in backwards-incompatible ways.

The patch also adds the corresponding integration test, which brings up
a dovecot server with a custom configuration, and tests chasquid's
authentication against it.  If dovecot is not installed, the test is
skipped.
2018-02-10 23:18:31 +00:00
Alberto Bertogli
213bc63a95 Support submission (directly) over TLS (submissions/smtps/port 465)
This patch adds support for TLS-wrapped submission connections.

Instead of clients establishing a connection over plain text and then
using STARTTLS to switch over a TLS connection, this new mode allows the
clients to connect directly over TLS, like it's done in HTTPS.

This is not an official standard yet, but it's reasonably common in
practice, and provides some advantages over the traditional submission
port.

The default port is 465, commonly used for this; chasquid defaults to
systemd file descriptor passing as for the other protocols (for now).
2017-04-10 19:59:04 +01:00
Alberto Bertogli
159aa97e8a Change the default MDA binary to "maildrop"
The current default is "procmail" for historical reasons, but the
program has been unmaintained for years and its use is not generally
advisable.

This patch changes the default MDA binary to "maildrop", which is a more
modern and reasonable MDA to use.

We keep the courier.Procmail name for now, as that's internal, but it
may be changed later.  Its documentation is updated to note that the
name is just for reference but it actually works with almost any binary.
2017-03-08 00:19:45 +00:00
Alberto Bertogli
fea808f8e3 queue: Get the DSN domain from the message
Picking the domain used in the DSN message "From" header is more
complicated than it needs to be, causing confusing code paths and having
different uses for the hostname, which should be purely aesthetic.

This patch makes the queue pick the DSN "From" domain from the message
itself, by looking for a local domain in either the sender or the
original recipients. We should find at least one, otherwise it'd be
relaying.

This allows the code to be simplified, and we can narrow the scope of
the hostname option even further.
2016-11-03 00:51:59 +00:00
Alberto Bertogli
cf2b8ade65 etc: Add a skeleton configuration structure
This patch adds an "etc" directory, with a basic configuration structure
that can be used for an initial installation.
2016-11-01 23:56:04 +00:00
Alberto Bertogli
febe96697a maillog: Introduce a special-purpose mail logging package
The default INFO logs are more oriented towards debugging and can be
a bit too verbose when looking for high-level information.

This patch introduces a new "maillog" package, used to log messages of
particular relevance to mail transmission at a higher level.
2016-10-21 22:20:47 +01:00
Alberto Bertogli
498bb29585 config: Set defaults for suffix_separators and drop_characters
This patch sets common and practical defaults for the suffix_separators ("+")
and drop_character options (".").
2016-10-10 00:51:05 +01:00
Alberto Bertogli
1d3675a133 queue: Send delivery status notifications on failures
When we permanently failed to deliver to one or more recipients, send delivery
status notifications back to the sender.

To do this, we need to extend a couple of internal structures, to keep track
of the original destinations (so we can include them in the message, for
reference), and the hostname we're identifying ourselves as (this is arguable
but we're going with it for now, may change later).
2016-10-10 00:51:04 +01:00
Alberto Bertogli
c34c073c1c chasquid: Load and resolve aliases
This patch integrates the aliases resolution into the daemon and queue.

The queue now will resolve aliases at Put time.
2016-10-10 00:51:04 +01:00
Alberto Bertogli
9ed30a747b config: Add a "data_dir" option
This patch adds a "data_dir" option, that chasquid will use to store
persistent data. It defaults to "/var/lib/chasquid" (for now, at least).

Users will come in subsequent patches.
2016-10-10 00:51:04 +01:00
Alberto Bertogli
941eb9315c Distinguish between SMTP and submission ports
We want to be able to distinguish between connections for SMTP and connections
for submission, so we can make different policy decisions.

To do that, we first make the configuration aware of the different kinds of
addresses. This is done in this patch in a backwards-incompatible way, but at
this point in time it is ok to do so.

Then, we extend systemd's socket passing library to support socket naming, so
we can tell the different sockets apart. This is done via the
LISTEN_FDNAMES/FileDescriptorName mechanism.

And finally we make the server and connection types aware of the socket mode.
2016-10-10 00:50:24 +01:00
Alberto Bertogli
ff103c18c3 courier: Let the users configure the mail delivery agent
This patch adds configuration options for the MDA binary and command line
arguments, and changes the (soon to be renamed) procmail courier to make use
of them.
2016-07-16 12:33:51 +01:00
Alberto Bertogli
a809a3caa9 Basic configuration
This patch introduces a basic on disk configuration, comprised of a main
configuration file and per-domain directories.

It's still not complete, but will be extended in subsequent patches.
2015-11-01 02:19:12 +00:00