-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,29 @@ Ideal use-cases for service mail are: | |
Anything that is sensitive or otherwise not suited should instead be implemented | ||
as a feature on King Arthur or any other system with fine-grained access | ||
control. | ||
|
||
### Parsing Mail | ||
|
||
In scripts, you should use | ||
[`mblaze`](https://manpages.ubuntu.com/manpages/focal/en/man7/mblaze.7.html) | ||
utilities to parse inbound mail to scripts to avoid issues that may arise from | ||
manually parsing email files. | ||
|
||
As an example, from the `[email protected]` service: | ||
|
||
```sh | ||
# Read the entire email into a variable | ||
EMAIL=$(cat) | ||
|
||
# Extract the sender's email address | ||
SENDER=$(echo "$EMAIL" | maddr -a -h from -) | ||
|
||
# Extract the Message-ID of the original email | ||
MESSAGE_ID=$(echo "$EMAIL" | mhdr -h message-id -) | ||
|
||
# Extract the original Subject and prefix it with "Re: " if necessary | ||
ORIGINAL_SUBJECT=$(echo "$EMAIL" | mhdr -h subject -) | ||
|
||
# Construct the reply subject | ||
REPLY_SUBJECT="Re: $ORIGINAL_SUBJECT" | ||
``` |