Skip to content

Commit 0bb72d1

Browse files
committed
outbound_smtp_auth supporting XOAUTH2
1 parent 5bafd5c commit 0bb72d1

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed
Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
---
22
lastUpdated: "03/26/2020"
33
title: "outbound_smtp_auth"
4-
description: "This module enables users to specify authentication parameters for a given set of messages so that Momentum will authenticate against the peer server when it sends outbound mail It currently supports the AUTH LOGIN and AUTH PLAIN methods of authentication You can specify the parameters in configuration or in lua..."
4+
description: "This module enables users to specify authentication parameters for a given set of messages so that Momentum will authenticate against the peer server when it sends outbound mail It currently supports the AUTH LOGIN, AUTH PLAIN and AUTH XOAUTH2 methods of authentication You can specify the parameters in configuration or in lua..."
55
---
66

7-
<a name="idp22419360"></a>
7+
<a name="modules.outbound_smtp_auth"></a>
88

9-
This module enables users to specify authentication parameters for a given set of messages so that Momentum will authenticate against the peer server when it sends outbound mail. It currently supports the 'AUTH LOGIN' and 'AUTH PLAIN' methods of authentication. You can specify the parameters in configuration or in lua, or use a combination of both.
9+
This module enables users to specify authentication parameters for a given set of messages so that
10+
Momentum will authenticate against the peer server when it sends outbound mail. It currently
11+
supports the `AUTH LOGIN`, `AUTH PLAIN` and `AUTH XOAUTH2` methods of authentication.
12+
You can specify the parameters in configuration or in lua, or use a combination of both.
1013

1114
### Note
1215

1316
This module makes heavy use of message contexts to facilitate authentication. If it is enabled, you risk having extra I/O unless `keep_message_dicts_in_memory` is on.
1417

15-
**Configuration Change. ** This feature is available in Momentum 4.2 and later.
18+
** Configuration Change ** This module is refactored in Momentum 5.1, but this feature is available in Momentum 4.2 and later.
1619

1720
### <a name="modules.outbound_smtp_auth.configuration"></a> Configuration
1821

19-
Configuration variables are listed below. These values can all be changed and overridden by setting context variables with the same name as the options in lua. All variables are valid in the binding group, binding, domain, and global scopes.
22+
Configuration variables are listed below. These values can all be changed and overridden by setting
23+
message context variables with the same name as the options in lua.
24+
All variables are valid in the binding group, binding, domain, and global scopes.
2025

2126
<dl class="variablelist">
2227

23-
<dt>outbound_smtp_auth_key</dt>
24-
25-
<dd>
26-
27-
A unique key that can be used in lua to look up authorization details in a database. It enables you to easily trigger custom behavior based on a configuration scope. The default value is `false`.
28-
29-
</dd>
30-
3128
<dt>outbound_smtp_auth_pass</dt>
3229

3330
<dd>
3431

35-
The password that will be passed to the remote server. The default value is `false`.
32+
The password or auth token (e.g. for `AUTH XOAUTH2`)that will be passed to the remote server. The default value is not set.
3633

3734
### Note
3835

39-
Setting the password in configuration will leave it as plaintext. To set the password more securely, dynamically retrieve it from a data store in lua and set it in the context variable that corresponds to this option.
36+
Setting the password in configuration will leave it as plaintext.
37+
To set the password more securely, dynamically retrieve it from a data store in lua and
38+
set it in the context variable that corresponds to this option.
4039

4140
</dd>
4241

4342
<dt>outbound_smtp_auth_type</dt>
4443

4544
<dd>
4645

47-
Determines what authentication protocol should be used. The only supported values are 'PLAIN' and 'LOGIN'. The default value is `false`.
46+
Determines what authentication protocol should be used. The only supported values are 'PLAIN',
47+
'LOGIN' and 'XOAUTH2'. The default value is not set.
4848

4949
</dd>
5050

5151
<dt>outbound_smtp_auth_user</dt>
5252

5353
<dd>
5454

55-
The username that will be passed to the remote server. The default value is `false`.
55+
The username that will be passed to the remote server. The default value is not set.
5656

5757
</dd>
5858

@@ -64,21 +64,23 @@ Basic examples of usage are provided below.
6464

6565
The following example shows how you can extend the new hook and set the username and password in lua.
6666

67-
<a name="modules.outbound_smtp_auth.example.set_username_pw"></a>
67+
<a name="modules.outbound_smtp_auth.example.set_username_pw"></a>
6868

6969

7070
```
7171
function mod:outbound_smtp_auth_config(msg, ac, vctx)
72-
print('NOTICE: outbound_smtp_auth_config Lua hook called');
73-
print('NOTICE: msg:['.. tostring(msg) ..']')
74-
msg:context_set(VCTX_MESS, 'outbound_smtp_auth_user', 'foo')
75-
msg:context_set(VCTX_MESS, 'outbound_smtp_auth_pass', 'bar')
72+
--print('NOTICE: outbound_smtp_auth_config Lua hook called');
73+
msg:context_set(VCTX_MESS, 'outbound_smtp_auth_type', 'XOAUTH2')
74+
-- credential taken from example here:
75+
-- https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth
76+
msg:context_set(VCTX_MESS, 'outbound_smtp_auth_user', '[email protected]')
77+
msg:context_set(VCTX_MESS, 'outbound_smtp_auth_pass', 'EwBAAl3BAAUFFpUAo7J3Ve0bjLBWZWCclRC3EoAA')
7678
end
7779
```
7880

7981
The following example shows how to use the new configuration variables to set distinct authorization parameters for two different domains.
8082

81-
<a name="modules.outbound_smtp_auth.example.set_auth_parms"></a>
83+
<a name="modules.outbound_smtp_auth.example.set_auth_parms"></a>
8284

8385

8486
```
@@ -90,13 +92,17 @@ Domain "messagesystems.com" {
9092
Outbound_SMTP_AUTH_Type = "LOGIN"
9193
Outbound_SMTP_AUTH_User = "msys"
9294
Outbound_SMTP_AUTH_Pass = "msys"
93-
Outbound_SMTP_AUTH_Key = "somestring"
9495
}
9596
9697
Domain "sparkpost.com" {
9798
Outbound_SMTP_AUTH_Type = "PLAIN"
9899
Outbound_SMTP_AUTH_user = "sparkpost"
99100
Outbound_SMTP_AUTH_pass = "sparkpost"
100-
Outbound_SMTP_AUTH_Key = "someotherstring"
101101
}
102-
```
102+
103+
Domain "bird.com" {
104+
Outbound_SMTP_AUTH_Type = "XOAUTH2"
105+
Outbound_SMTP_AUTH_user = "[email protected]"
106+
Outbound_SMTP_AUTH_pass = "EwBAAl3BAAUFFpUAo7J3Ve0bjLBWZWCclRC3EoAA"
107+
}
108+
```

0 commit comments

Comments
 (0)