Files
kumomta/docs/reference/events/smtp_server_ehlo.md
T
Wez Furlong 49eb0a634c smtp_server_ehlo: pass in and allow returning a list of extensions
This is helpful in situations where you need to do things that
are not strictly supported but might just happen to squeak by
if support is claimed for them.
2025-01-09 11:03:11 -07:00

1.6 KiB

kumo.on('smtp_server_ehlo', function(domain, conn_meta))

Called by the ESMTP server in response to the client issuing either a "HELO" or "EHLO" command. The event handler is passed the domain parameter from the HELO/EHLO command.

{{since('2023.08.22-4d895015', indent=True)}} The conn_meta parameter represents the connection metadata and can be used to share state between the various SMTP listener event handlers. See Connection Metadata for more information.

You may choose to reject the connection via kumo.reject.

-- Called to validate the helo and/or ehlo domain
kumo.on('smtp_server_ehlo', function(domain, conn_meta)
  -- Use kumo.reject to return an error to the EHLO command
  if domain == 'bad.actor' then
    kumo.reject(420, 'go away')
  end
end)

{{since('dev')}}

The signature of the call has been extended to receive the list of SMTP extensions that will be reported by the EHLO command. You can optionally return a list of extensions to replace that list.

This example shows how to advertise support for a hypothetical "X-SOMETHING" extension:

kumo.on('smtp_server_ehlo', function(domain, conn_meta, extensions)
  table.insert(extensions, 'X-SOMETHING')
  return extensions
end)

If you return nil or otherwise omit to return anything, the standard set of extensions will be returned.

You can filter out or add whatever strings you wish from the extensions parameter, but it is worth noting that what you add/remove from this list has no impact on what kumomta actually supports, and does not otherwise change its behavior.