Skip to main content

outbound_smtp_auth

Last updated March 2020

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.

Note

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.

**Configuration Change. ** This feature is available in Momentum 4.2 and later.

Configuration

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.

outbound_smtp_auth_key

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.

outbound_smtp_auth_pass

The password that will be passed to the remote server. The default value is false.

Note

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.

outbound_smtp_auth_type

Determines what authentication protocol should be used. The only supported values are 'PLAIN' and 'LOGIN'. The default value is false.

outbound_smtp_auth_user

The username that will be passed to the remote server. The default value is false.

Usage

Basic examples of usage are provided below.

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

function mod:outbound_smtp_auth_config(msg, ac, vctx)
  print('NOTICE: outbound_smtp_auth_config Lua hook called');
  print('NOTICE: msg:['.. tostring(msg) ..']')
  msg:context_set(VCTX_MESS, 'outbound_smtp_auth_user', 'foo')
  msg:context_set(VCTX_MESS, 'outbound_smtp_auth_pass', 'bar')
end

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

outbound_smtp_auth { }

Keep_Message_Dicts_In_Memory = true

Domain "messagesystems.com" {
  Outbound_SMTP_AUTH_Type = "LOGIN"
  Outbound_SMTP_AUTH_User = "msys"
  Outbound_SMTP_AUTH_Pass = "msys"
  Outbound_SMTP_AUTH_Key = "somestring"
}

Domain "sparkpost.com" {
  Outbound_SMTP_AUTH_Type = "PLAIN"
  Outbound_SMTP_AUTH_user = "sparkpost"
  Outbound_SMTP_AUTH_pass = "sparkpost"
  Outbound_SMTP_AUTH_Key = "someotherstring"
}
Was this page helpful?