Skip to content

Commit

Permalink
feat: add smtp auth login support
Browse files Browse the repository at this point in the history
  • Loading branch information
buroa committed Feb 25, 2024
1 parent 1d6cd8c commit a87a9c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/reference/targets/smtp.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Refuse to pass messages over plain-text connections.

---

### auth `off` | `plain` _username_ _password_ | `forward` | `external`
### auth `off` | `plain` _username_ _password_ | `login` _username_ _password_ | `forward` | `external`
Default: `off`

Specify the way to authenticate to the remote server.
Expand All @@ -74,6 +74,10 @@ Valid values:
- `off` – No authentication.
- `plain` – Authenticate using specified username-password pair.
**Don't use** this without enforced TLS (`require_tls`).
- `login` - Authenticate using specified username-password pair.
Uses obsolete SASL LOGIN mechanism instead of SASL PLAIN.
This is required for compatibility with some SMTP services (e.g. Office 365).
**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`).
- `external` – Request "external" SASL authentication. This is usually used for
Expand Down
7 changes: 7 additions & 0 deletions internal/target/smtp/sasl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit a87a9c0

Please sign in to comment.