User Tools

Site Tools


reference:outgoing_message_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
reference:outgoing_message_script [2018/11/14 10:45] – external edit 127.0.0.1reference:outgoing_message_script [2024/03/21 10:49] (current) paul
Line 23: Line 23:
   * HoldSeconds - The current number of seconds the message will be held before being sent (0 = no time).   * HoldSeconds - The current number of seconds the message will be held before being sent (0 = no time).
   * DeleteAfterSeconds - The current number of seconds before the message will be deleted from the queue (0 = never).   * DeleteAfterSeconds - The current number of seconds before the message will be deleted from the queue (0 = never).
 +  * HoldTimeFromSender - The ISO-8601 time to hold to as defined at message send time (eg by 'FUTURERELEASE') (added in v8.6)
 +  * DeleteTimeFromSender - The ISO-8601 time to delete the message at as defined at message send time (added in v8.6)
  
 The function returns a table of new settings. This can contain the following fields. If the field doesn't exist, then the value is not changed. The function returns a table of new settings. This can contain the following fields. If the field doesn't exist, then the value is not changed.
Line 30: Line 32:
   * HoldUntil - If this is set to a string like YYYYMMDDHHMMSS then the message is held until that time, otherwise it is held for the specified number of seconds.   * HoldUntil - If this is set to a string like YYYYMMDDHHMMSS then the message is held until that time, otherwise it is held for the specified number of seconds.
   * DeleteAfter - If this is set to 'none', then it is never deleted. If this is set to a string like YYYYMMDDHHMMSS then the message will be deleted after that time, otherwise it will be deleted after the specified number of seconds.   * DeleteAfter - If this is set to 'none', then it is never deleted. If this is set to a string like YYYYMMDDHHMMSS then the message will be deleted after that time, otherwise it will be deleted after the specified number of seconds.
 +  * ReturnPath - (added in v8.6) - A new value for the ReturnPath (MAILFROM) of the message being sent
 +
 +====Examples====
 +Example from a customer to change the ReturnPath depending on the 'From' address in the header
 +
 +<code lua>
 +-- change ReturnPath with address-only according to address in From-Field
 +-- Copyright 2024 AT Software und Rechnertechnik GmbH Muenchen
 +-- last change 09.03.2024 AT/ath
 +function NewMessage(AuthenticatedSender, ReturnPath, CreationDate, Subject, SenderIPAddress, FileLength, Priority, Headers)
 + actions = {}
 + SenderAddressTo = "..."
 + SenderSubject = "..."
 + MessageHeadersChanged = false
 + for k,v in pairs(Headers) do
 + if string.upper(v[1]) == "SUBJECT" then
 +            SenderSubject = v[2]
 +            if not SenderSubject then SenderSubject = "..." end
 + end
 + if string.upper(v[1]) == "TO" then
 +     SenderAddressTo = v[2]
 +            if not SenderAddressTo then SenderAddressTo = "..." end
 + end
 + if string.upper(v[1]) == "FROM" then
 +     -- SenderAddressFrom = "Alexander <alexander@my-secondcompany.com>"
 + SenderAddressFrom = v[2]
 +            if string.find(SenderAddressFrom, "@my%-secondcompany%.com") then
 +                JustTheAddress = string.match(SenderAddressFrom, " <%g*@my%-secondcompany%.com>")
 +                JustTheAddress = string.sub(JustTheAddress, 3, string.len(JustTheAddress)-1) -- remove trailing and ending brackets
 +                -- OldReturnPath = "alexander@firstcompany.com"
 +                OldReturnPath = ReturnPath
 +                -- actions["returnpath"] = "alexander@my-secondcompany.com"
 +                actions["returnpath"] = JustTheAddress
 +                MessageHeadersChanged = true
 +                print("Changed ReturnPath in message from '" .. SenderAddressFrom .. "' from '" .. OldReturnPath .. "' to '" .. JustTheAddress .. "' for message to '" .. SenderAddressTo .. "' with Subject '" .. SenderSubject .. "'")
 + end
 + end
 +    end
 +    if not MessageHeadersChanged then
 +        print("Nothing changed in message from '" .. SenderAddressFrom .. "' for message to '" .. SenderAddressTo .. "' with Subject '" .. SenderSubject .. "'")
 +    end
 + return actions
 +end
 +</code>
  
reference/outgoing_message_script.1542192349.txt.gz · Last modified: 2018/11/14 10:45 by 127.0.0.1