Skip to content

Commit f64a731

Browse files
committed
Additional licensing information and more indepth readme
1 parent 057145b commit f64a731

3 files changed

Lines changed: 51 additions & 17 deletions

File tree

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,47 @@
11

2-
## Imap Extractor
2+
# Imap Extractor
33

44
This is a very basic tool to scan an email-inbox for certain content.
55

6-
The parameters are passed through a configuration file in json format, an example can be seen in "example-config.json".
6+
The parameters are passed through a configuration file in json format, an example can be seen in below.
77
The path to said configuration shall be passed as first parameter of the program.
88

9+
Disclaimer: This tool was just a quick implementation for our CI needs, which might also be useful for others.
10+
11+
12+
##Usage:
13+
To call the program use:
14+
```
15+
imap-extractor <path to config json>
16+
```
17+
18+
For detailed description of config json see below. Configured regex needs to contain at least one group.
19+
Result will be content of group of first match found in the email inbox.
20+
Additional unnamed groups may be used inside the regex.
21+
22+
##Parameters:
23+
924
The following configurations are to be included in the configuration:
1025
* imap-host: Url on which the email host can be reached
11-
* imap-port: Port on which the IMAP protocol is offered
26+
* imap-port: Port on which the IMAP protocol is offered (Usually 143 or 993)
1227
* username: Login username for email host
1328
* password: Password for above username
1429
* from-filter: Name filter for email origin
1530
* regexp: Regex for which the emails will be scanned, including a group for the result
1631

1732

1833
On execution this program will go through the inbox of given email address from newest to oldest.
19-
Once any match with the given regex is found, the content of the first capturing group in the regex will be returned.
34+
Once any match with the given regex is found, the content of the first capturing group in the regex will be returned.
35+
36+
37+
##Config Example:
38+
```json
39+
{
40+
"imap-host": "mobiuscode.de/",
41+
"imap-port": 993,
42+
"username": "user@mobiuscode.de",
43+
"password": "tryOutPanicMode",
44+
"from-filter": "boss@mobiuscode.de",
45+
"regexp": "please see important thing below:(?:[\\s]+)([\\S]+)(?:[\\s]+)"
46+
}
47+
```

example-config.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

imapExtractor.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2022 MobiusCode GmbH
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
package main
216

317
import (
@@ -18,17 +32,17 @@ import (
1832

1933
type Config struct {
2034
// Host URL on which the emails are received
21-
ImapHost string `json:"imap-host"`
35+
ImapHost string `json:"imap-host"`
2236
// Port for the IMAP protocol
23-
ImapPort int `json:"imap-port"`
37+
ImapPort int `json:"imap-port"`
2438
// Email-User for login
25-
EmailUser string `json:"username"`
39+
EmailUser string `json:"username"`
2640
// Corresponding password
2741
EmailPassword string `json:"password"`
2842
// Filter for the "from" email field (Name, not email)
29-
FromFilter string `json:"from-filter"`
43+
FromFilter string `json:"from-filter"`
3044
// Regex to be scanned for, first matched group is used as a result
31-
ContentRegex string `json:"regexp"`
45+
ContentRegex string `json:"regexp"`
3246
}
3347

3448
func main() {

0 commit comments

Comments
 (0)