[mail] Add support for e-mail headers (#11307)

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
Andrew Fiddian-Green
2021-09-27 09:38:13 +01:00
committed by GitHub
parent 8255f29320
commit b2db32da96
5 changed files with 76 additions and 0 deletions

View File

@@ -127,3 +127,23 @@ val List<String> attachmentUrlList = newArrayList(
val mailActions = getActions("mail","mail:smtp:sampleserver")
mailActions.sendHtmlMail("mail@example.com", "Test subject", "<h1>Header</h1>This is the mail content.", attachmentUrlList)
```
## Mail Headers
The binding allows one to add custom e-mail headers to messages that it sends.
For example if you want e-mails sent by this binding to be grouped into a "threaded view" in your email client, you must provide an e-mail "Reference" header, which acts as the key for grouping messages together.
Headers can be added inside a rule by calling the `mailActions.addHeader()` method before calling the respective `mailActions.sendMail()` method.
See the example below.
```
rule "Send Mail with a 'Reference' header; for threaded view in e-mail client"
when
...
then
val mailActions = getActions("mail","mail:smtp:sampleserver")
mailActions.addHeader("Reference", "<unique-thread-identifier>")
mailActions.sendMail("mail@example.com", "Test subject", "Test message text")
end
```
Note: in the case of the "Reference" header, the `<unique-thread-identifier>` has to be an ASCII string enclosed in angle brackets.