Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smtp_proxy: handle dead sender more gracefully #3286

Merged
merged 2 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions docs/plugins/queue/smtp_proxy.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
# queue/smtp\_proxy
================

This plugin delivers to another mail server. This is a common setup when you
want to have a mail server with a solid pedigree of outbound delivery to
other hosts, and inbound delivery to users.

In comparison to `queue/smtp_forward`, this plugin makes a connection at
MAIL FROM time to the ongoing SMTP server. This can be a benefit in that
you get any SMTP-time filtering that the ongoing server provides, in
particular one important facility to some setups is recipient filtering.
However be aware that other than connect and HELO-time filtering, you will
have as many connections to your ongoing SMTP server as you have to Haraka.
This plugin delivers to another mail server. This is a common setup when you want to have a mail server with a solid pedigree of outbound delivery to other hosts, and inbound delivery to users.

In comparison to `queue/smtp_forward`, this plugin makes a connection at MAIL FROM time to the ongoing SMTP server. This can be a benefit in that you get any SMTP-time filtering that the ongoing server provides, in particular one important facility to some setups is recipient filtering.

Be aware that other than connect and HELO-time filtering, you will have as many connections to your ongoing SMTP server as you have to Haraka.

## Configuration
-------------
Expand Down
3 changes: 1 addition & 2 deletions plugins/queue/smtp_forward.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ exports.queue_forward = function (next, connection) {
);

function get_rs () {
if (txn) return txn.results;
return connection.results;
return connection?.transaction?.results ? connection.transaction.results : connection.results
}

function dead_sender () {
Expand Down
11 changes: 10 additions & 1 deletion plugins/queue/smtp_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,22 @@ exports.hook_mail = function (next, connection, params) {
exports.hook_rcpt_ok = (next, connection, recipient) => {
const { smtp_client } = connection.notes;
if (!smtp_client) return next();
if (smtp_client.is_dead_sender(this, connection)) {
delete connection.notes.smtp_client;
return;
}
smtp_client.next = next;
smtp_client.send_command('RCPT', `TO:${recipient.format(!smtp_client.smtp_utf8)}`);
}

exports.hook_data = (next, connection) => {
const { smtp_client } = connection.notes;
if (!smtp_client) return next();

if (smtp_client.is_dead_sender(this, connection)) {
delete connection.notes.smtp_client;
return;
}
smtp_client.next = next;
smtp_client.send_command("DATA");
}
Expand All @@ -96,11 +105,11 @@ exports.hook_queue = function (next, connection) {
const { smtp_client } = connection.notes;
if (!smtp_client) return next();

smtp_client.next = next;
if (smtp_client.is_dead_sender(this, connection)) {
delete connection.notes.smtp_client;
return;
}
smtp_client.next = next;
smtp_client.start_data(connection.transaction.message_stream);
}

Expand Down
Loading