myl-discovery 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl
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.dist-info → myl_discovery-0.2.0.dist-info}/METADATA +4 -3
- myl_discovery-0.2.0.dist-info/RECORD +6 -0
- myldiscovery/__init__.py +39 -16
- myl_discovery-0.1.0.dist-info/RECORD +0 -6
- {myl_discovery-0.1.0.dist-info → myl_discovery-0.2.0.dist-info}/LICENSE +0 -0
- {myl_discovery-0.1.0.dist-info → myl_discovery-0.2.0.dist-info}/WHEEL +0 -0
- {myl_discovery-0.1.0.dist-info → myl_discovery-0.2.0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: myl-discovery
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.0
|
4
4
|
Summary: email autodiscovery
|
5
5
|
Author-email: Philipp Schmitt <philipp@schmitt.co>
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
@@ -697,12 +697,13 @@ Email autoconfig library
|
|
697
697
|
pip install myl-discovery
|
698
698
|
```
|
699
699
|
|
700
|
-
## Usage
|
700
|
+
## Usage
|
701
701
|
|
702
702
|
```python
|
703
703
|
from myldiscovery import autodiscover
|
704
704
|
autodiscover("me@example.com")
|
705
|
-
# {'server': 'mail.example.com', 'port':
|
705
|
+
# {'imap': {'server': 'mail.example.com', 'port': 993, 'starttls': False},
|
706
|
+
# 'smtp': {'server': 'mail.example.com', 'port': 587, 'starttls': False}}
|
706
707
|
```
|
707
708
|
|
708
709
|
|
@@ -0,0 +1,6 @@
|
|
1
|
+
myldiscovery/__init__.py,sha256=pGTsuY2G9_Az6DKftLsQM9vBbcNIAy8q2vPRh3486XA,2950
|
2
|
+
myl_discovery-0.2.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
3
|
+
myl_discovery-0.2.0.dist-info/METADATA,sha256=rEmMa99hvijh3l8VCmvDui8DyugVVIAu4c1IL49q9nA,41297
|
4
|
+
myl_discovery-0.2.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
5
|
+
myl_discovery-0.2.0.dist-info/top_level.txt,sha256=v_h72JexaacqBNY6iOMD9PpGg8lnGoL-pkmUIzxdiVU,13
|
6
|
+
myl_discovery-0.2.0.dist-info/RECORD,,
|
myldiscovery/__init__.py
CHANGED
@@ -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
|
}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
myldiscovery/__init__.py,sha256=xalUlWBnrOfGhkQL6ipCF2qJrTPF1yjkKpD4pibkMrk,2149
|
2
|
-
myl_discovery-0.1.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
3
|
-
myl_discovery-0.1.0.dist-info/METADATA,sha256=8U3XgyA-Mudg3Y3lxnlh1JkdbB3MKEi3IEzNzWT1-lA,41212
|
4
|
-
myl_discovery-0.1.0.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
|
5
|
-
myl_discovery-0.1.0.dist-info/top_level.txt,sha256=v_h72JexaacqBNY6iOMD9PpGg8lnGoL-pkmUIzxdiVU,13
|
6
|
-
myl_discovery-0.1.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|