Files
kumomta/docs/reference/message/import_scheduling_header.md
T
Wez Furlong c2444b6266 add expiry to per-msg scheduling overrides
This commit allows setting a per-message `expires` timestamp
via msg:set_scheduling (and thus msg:import_scheduling_header).

The expiration takes precedence over max_age; max_age will be
ignored for messages that have configured and expiration time.

The expiration time is independent of the other scheduling
restrictions.
2025-03-15 07:18:13 -07:00

1.3 KiB

message:import_scheduling_header(HEADER_NAME, REMOVE)

Reads the header specified and attempts to parse it as JSON-encoded version of the message:set_scheduling() parameters. If successful, it will call message:set_scheduling() with that value, and if REMOVE is set to true, will remove the header from the message.

The return value of message:import_scheduling_header is:

  • A lua table representation of the scheduling parameters, or nil if the specified header was not present. {{since('dev', inline=True)}}
  • nil in prior versions of KumoMTA.

If the header is present, but has invalid contents the behavior will be:

  • An error will be raised explaining the issue. {{since('dev', inline=True)}}
  • No error indication will be given and no errors will be logged in prior versions of KumoMTA.

For example, given this message:

X-Schedule: {"dow":"Mon,Wed","tz":"America/Phoenix","start":"09:00:00","end":"17:00:00"}
Subject: hello

This message should only be delivered during working hours
in Phoenix on Mondays or Wednesdays.

this policy script will parse and remove that header, and apply the scheduling constraints:

kumo.on('smtp_server_message_received', function(msg)
  msg:import_scheduling_header('X-Schedule', true)
end)