From 0b883ed1d2b2c1eb055d40c15649e0a9b9afb8f1 Mon Sep 17 00:00:00 2001 From: Steven Kreitzer Date: Fri, 23 Feb 2024 12:05:21 -0600 Subject: [PATCH] feat: add smtp auth login support --- docs/reference/targets/smtp.md | 4 ++-- internal/target/smtp/sasl.go | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/reference/targets/smtp.md b/docs/reference/targets/smtp.md index 7ee56abd..1a37221b 100644 --- a/docs/reference/targets/smtp.md +++ b/docs/reference/targets/smtp.md @@ -65,14 +65,14 @@ Refuse to pass messages over plain-text connections. --- -### auth `off` | `plain` _username_ _password_ | `forward` | `external` +### auth `off` | `plain` _username_ _password_ | `auth` _username_ _password_ | `forward` | `external` Default: `off` Specify the way to authenticate to the remote server. Valid values: - `off` – No authentication. -- `plain` – Authenticate using specified username-password pair. +- `plain` or `auth` – Authenticate using specified username-password pair. **Don't use** this without enforced TLS (`require_tls`). - `forward` – Forward credentials specified by the client. **Don't use** this without enforced TLS (`require_tls`). diff --git a/internal/target/smtp/sasl.go b/internal/target/smtp/sasl.go index 75f5d4e5..6af22e44 100644 --- a/internal/target/smtp/sasl.go +++ b/internal/target/smtp/sasl.go @@ -64,6 +64,13 @@ func saslAuthDirective(_ *config.Map, node config.Node) (interface{}, error) { return func(*module.MsgMetadata) (sasl.Client, error) { return sasl.NewPlainClient("", node.Args[1], node.Args[2]), nil }, nil + case "login": + if len(node.Args) != 3 { + return nil, config.NodeErr(node, "two additional arguments are required (username, password)") + } + return func(*module.MsgMetadata) (sasl.Client, error) { + return sasl.NewLoginClient(node.Args[1], node.Args[2]), nil + }, nil case "external": if len(node.Args) > 1 { return nil, config.NodeErr(node, "no additional arguments required")