Skip to content

feat(transport): Custom SMTP transport#104

Draft
j-g00da wants to merge 1 commit intomainfrom
j-g00da/mxdeliv
Draft

feat(transport): Custom SMTP transport#104
j-g00da wants to merge 1 commit intomainfrom
j-g00da/mxdeliv

Conversation

@j-g00da
Copy link
Copy Markdown
Collaborator

@j-g00da j-g00da commented Mar 23, 2026

Implements a new mode "transport",
that allows filtermail to be used as a
postfix pipe transport replacing postfix smtp client.

SMTP client tries to open socket on all resolved
addresses in parallel and uses one that succeeds
the first, fixing the issue described in:
chatmail/relay#900

Extends the built-in SMTP client
with STARTTLS support.

Groundwork required for mxdeliv endpoint
(HTTP channel for MTA-to-MTA communication):
chatmail/relay#900

@j-g00da
Copy link
Copy Markdown
Collaborator Author

j-g00da commented Mar 23, 2026

Note: I only just read #41 (comment) - this may be the correct way of handling this, I didn't include docs as these will probably have to be changed.

Nevertheless, some of this can still be reviewed, especially changes to the smtp_client module (STARTTLS handling; connecting to all resolved addresses in parallel).

src/main.rs Outdated
Comment on lines +141 to +164
let handler = Arc::new(
// We want to panic here if the handler cannot be created.
IncomingBeforeQueueHandler::new(config.clone(), skip_dkim).unwrap(),
);
let max_size = config.max_message_size;

let mut server_set = tokio::task::JoinSet::new();

let addr_smtp = (config.filtermail_host, config.filtermail_smtp_port_incoming);
let handler_smtp = handler.clone();
server_set
.spawn(async move { run_smtp_server(&addr_smtp, handler_smtp, max_size).await });
log::debug!(
"Incoming SMTP server listening on {}:{}",
addr_smtp.0,
addr_smtp.1
);

while let Some(result) = server_set.join_next().await {
if let Err(e) = result {
eprintln!("Server error: {}", e);
process::exit(1);
}
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a groundwork for mxdeliv as this way I can later easily spawn here a http server along smtp one.

@j-g00da j-g00da marked this pull request as draft March 24, 2026 12:01
Signed-off-by: Jagoda Ślązak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants