myl-discovery 0.1.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/PKG-INFO +4 -3
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/README.md +3 -2
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/myl_discovery.egg-info/PKG-INFO +4 -3
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/myl_discovery.egg-info/SOURCES.txt +5 -1
- myl-discovery-0.3.0/myl_discovery.egg-info/entry_points.txt +2 -0
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/myl_discovery.egg-info/requires.txt +1 -0
- myl-discovery-0.3.0/myldiscovery/__init__.py +4 -0
- myl-discovery-0.3.0/myldiscovery/__main__.py +4 -0
- myl-discovery-0.1.0/myldiscovery/__init__.py → myl-discovery-0.3.0/myldiscovery/discovery.py +39 -16
- myl-discovery-0.3.0/myldiscovery/main.py +64 -0
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/pyproject.toml +5 -1
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/.github/dependabot.yml +0 -0
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/.github/workflows/lint.yaml +0 -0
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/.github/workflows/release.yaml +0 -0
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/.gitignore +0 -0
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/LICENSE +0 -0
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/myl_discovery.egg-info/dependency_links.txt +0 -0
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/myl_discovery.egg-info/top_level.txt +0 -0
- {myl-discovery-0.1.0 → myl-discovery-0.3.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: myl-discovery
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: email autodiscovery
|
5
5
|
Author-email: Philipp Schmitt <philipp@schmitt.co>
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
@@ -694,12 +694,13 @@ Email autoconfig library
|
|
694
694
|
pip install myl-discovery
|
695
695
|
```
|
696
696
|
|
697
|
-
## Usage
|
697
|
+
## Usage
|
698
698
|
|
699
699
|
```python
|
700
700
|
from myldiscovery import autodiscover
|
701
701
|
autodiscover("me@example.com")
|
702
|
-
# {'server': 'mail.example.com', 'port':
|
702
|
+
# {'imap': {'server': 'mail.example.com', 'port': 993, 'starttls': False},
|
703
|
+
# 'smtp': {'server': 'mail.example.com', 'port': 587, 'starttls': False}}
|
703
704
|
```
|
704
705
|
|
705
706
|
|
@@ -8,12 +8,13 @@ Email autoconfig library
|
|
8
8
|
pip install myl-discovery
|
9
9
|
```
|
10
10
|
|
11
|
-
## Usage
|
11
|
+
## Usage
|
12
12
|
|
13
13
|
```python
|
14
14
|
from myldiscovery import autodiscover
|
15
15
|
autodiscover("me@example.com")
|
16
|
-
# {'server': 'mail.example.com', 'port':
|
16
|
+
# {'imap': {'server': 'mail.example.com', 'port': 993, 'starttls': False},
|
17
|
+
# 'smtp': {'server': 'mail.example.com', 'port': 587, 'starttls': False}}
|
17
18
|
```
|
18
19
|
|
19
20
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: myl-discovery
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.3.0
|
4
4
|
Summary: email autodiscovery
|
5
5
|
Author-email: Philipp Schmitt <philipp@schmitt.co>
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
@@ -694,12 +694,13 @@ Email autoconfig library
|
|
694
694
|
pip install myl-discovery
|
695
695
|
```
|
696
696
|
|
697
|
-
## Usage
|
697
|
+
## Usage
|
698
698
|
|
699
699
|
```python
|
700
700
|
from myldiscovery import autodiscover
|
701
701
|
autodiscover("me@example.com")
|
702
|
-
# {'server': 'mail.example.com', 'port':
|
702
|
+
# {'imap': {'server': 'mail.example.com', 'port': 993, 'starttls': False},
|
703
|
+
# 'smtp': {'server': 'mail.example.com', 'port': 587, 'starttls': False}}
|
703
704
|
```
|
704
705
|
|
705
706
|
|
@@ -8,6 +8,10 @@ pyproject.toml
|
|
8
8
|
myl_discovery.egg-info/PKG-INFO
|
9
9
|
myl_discovery.egg-info/SOURCES.txt
|
10
10
|
myl_discovery.egg-info/dependency_links.txt
|
11
|
+
myl_discovery.egg-info/entry_points.txt
|
11
12
|
myl_discovery.egg-info/requires.txt
|
12
13
|
myl_discovery.egg-info/top_level.txt
|
13
|
-
myldiscovery/__init__.py
|
14
|
+
myldiscovery/__init__.py
|
15
|
+
myldiscovery/__main__.py
|
16
|
+
myldiscovery/discovery.py
|
17
|
+
myldiscovery/main.py
|
myl-discovery-0.1.0/myldiscovery/__init__.py → myl-discovery-0.3.0/myldiscovery/discovery.py
RENAMED
@@ -44,21 +44,36 @@ def autodiscover_txt(domain):
|
|
44
44
|
return res.split("=")[1]
|
45
45
|
|
46
46
|
|
47
|
-
def autodiscover(email_addr):
|
47
|
+
def autodiscover(email_addr, srv_only=False):
|
48
48
|
domain = email_addr.split("@")[-1]
|
49
49
|
if not domain:
|
50
50
|
raise ValueError(f"Invalid email address {email_addr}")
|
51
51
|
|
52
|
-
autoconfig = autodiscover_txt(domain)
|
52
|
+
autoconfig = autodiscover_txt(domain) if not srv_only else None
|
53
53
|
|
54
54
|
if not autoconfig:
|
55
|
-
|
55
|
+
imap = resolve_srv(f"_imaps._tcp.{domain}")
|
56
|
+
smtp = resolve_srv(f"_submission._tcp.{domain}")
|
57
|
+
|
56
58
|
return {
|
57
|
-
"
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
"imap": {
|
60
|
+
"server": imap[0].get("hostname"),
|
61
|
+
"port": int(imap[0].get("port")),
|
62
|
+
# FIXME We might want to "smartly" guess if starttls should be
|
63
|
+
# enabled or not, depending on the port:
|
64
|
+
# 143 -> starttls
|
65
|
+
# 993 -> no
|
66
|
+
"starttls": False,
|
67
|
+
},
|
68
|
+
"smtp": {
|
69
|
+
"server": smtp[0].get("hostname"),
|
70
|
+
"port": int(smtp[0].get("port")),
|
71
|
+
# FIXME We might want to "smartly" guess if starttls should be
|
72
|
+
# enabled or not, depending on the port:
|
73
|
+
# 465 -> starttls
|
74
|
+
# 587 -> no
|
75
|
+
"starttls": False,
|
76
|
+
},
|
62
77
|
}
|
63
78
|
|
64
79
|
res = requests.get(autoconfig)
|
@@ -70,16 +85,24 @@ def autodiscover(email_addr):
|
|
70
85
|
.get("emailProvider", {})
|
71
86
|
.get("incomingServer")
|
72
87
|
)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
88
|
+
smtp = (
|
89
|
+
data.get("clientConfig", {})
|
90
|
+
.get("emailProvider", {})
|
91
|
+
.get("outgoingServer")
|
92
|
+
)
|
78
93
|
|
79
94
|
assert imap is not None
|
95
|
+
assert smtp is not None
|
80
96
|
|
81
97
|
return {
|
82
|
-
"
|
83
|
-
|
84
|
-
|
98
|
+
"imap": {
|
99
|
+
"server": imap.get("hostname"),
|
100
|
+
"port": int(imap.get("port")),
|
101
|
+
"starttls": imap.get("socketType") == "STARTTLS",
|
102
|
+
},
|
103
|
+
"smtp": {
|
104
|
+
"server": smtp.get("hostname"),
|
105
|
+
"port": int(smtp.get("port")),
|
106
|
+
"starttls": smtp.get("socketType") == "STARTTLS",
|
107
|
+
},
|
85
108
|
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
import argparse
|
5
|
+
import logging
|
6
|
+
|
7
|
+
from rich import print_json
|
8
|
+
from rich.console import Console
|
9
|
+
from rich.logging import RichHandler
|
10
|
+
from rich.table import Table
|
11
|
+
|
12
|
+
from myldiscovery import autodiscover
|
13
|
+
|
14
|
+
LOGGER = logging.getLogger(__name__)
|
15
|
+
|
16
|
+
|
17
|
+
def parse_args():
|
18
|
+
parser = argparse.ArgumentParser()
|
19
|
+
parser.add_argument("-j", "--json", action="store_true", default=False)
|
20
|
+
parser.add_argument("-d", "--debug", action="store_true", default=False)
|
21
|
+
parser.add_argument("EMAIL")
|
22
|
+
return parser.parse_args()
|
23
|
+
|
24
|
+
|
25
|
+
def main():
|
26
|
+
console = Console()
|
27
|
+
args = parse_args()
|
28
|
+
|
29
|
+
logging.basicConfig(
|
30
|
+
handlers=[RichHandler(console=console, show_time=False)],
|
31
|
+
level=logging.DEBUG if args.debug else logging.INFO,
|
32
|
+
)
|
33
|
+
LOGGER.debug(args)
|
34
|
+
|
35
|
+
try:
|
36
|
+
res = autodiscover(args.EMAIL)
|
37
|
+
if args.json:
|
38
|
+
print_json(data=res)
|
39
|
+
else:
|
40
|
+
table = Table(
|
41
|
+
expand=True,
|
42
|
+
show_header=True,
|
43
|
+
header_style="bold",
|
44
|
+
show_lines=False,
|
45
|
+
box=None,
|
46
|
+
)
|
47
|
+
table.add_column("Service", style="red")
|
48
|
+
table.add_column("Host", style="blue")
|
49
|
+
table.add_column("Port", style="green")
|
50
|
+
table.add_column("TLS", style="yellow")
|
51
|
+
for svc in ["imap", "smtp"]:
|
52
|
+
table.add_row(
|
53
|
+
svc,
|
54
|
+
res[svc]["server"],
|
55
|
+
str(res[svc]["port"]),
|
56
|
+
"starttls" if res[svc]["starttls"] else "tls",
|
57
|
+
)
|
58
|
+
console.print(table)
|
59
|
+
except Exception:
|
60
|
+
console.print_exception(show_locals=True)
|
61
|
+
|
62
|
+
|
63
|
+
if __name__ == "__main__":
|
64
|
+
main()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|