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 cbd5836
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/reference/targets/smtp.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ Refuse to pass messages over plain-text connections.

---

### auth `off` | `plain` _username_ _password_ | `forward` | `external`
### auth `off` | `plain|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`).
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 cbd5836

Please sign in to comment.