myl-discovery 0.5.2__tar.gz → 0.5.4__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.5.2/README.md → myl-discovery-0.5.4/HACKING.md +0 -20
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/PKG-INFO +65 -103
- myl-discovery-0.5.4/README.md +89 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/myl_discovery.egg-info/PKG-INFO +65 -103
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/myl_discovery.egg-info/SOURCES.txt +1 -0
- myl-discovery-0.5.4/myldiscovery/__init__.py +19 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/myldiscovery/discovery.py +74 -53
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/pyproject.toml +1 -1
- myl-discovery-0.5.2/myldiscovery/__init__.py +0 -4
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/.github/dependabot.yml +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/.github/workflows/lint.yaml +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/.github/workflows/pypi.yaml +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/.github/workflows/release.yaml +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/.gitignore +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/LICENSE +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/myl_discovery.egg-info/dependency_links.txt +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/myl_discovery.egg-info/entry_points.txt +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/myl_discovery.egg-info/requires.txt +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/myl_discovery.egg-info/top_level.txt +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/myldiscovery/__main__.py +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/myldiscovery/main.py +0 -0
- {myl-discovery-0.5.2 → myl-discovery-0.5.4}/setup.cfg +0 -0
@@ -1,23 +1,3 @@
|
|
1
|
-
# myl-discovery
|
2
|
-
|
3
|
-
Email autoconfig library
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
```shell
|
8
|
-
pip install myl-discovery
|
9
|
-
```
|
10
|
-
|
11
|
-
## Usage
|
12
|
-
|
13
|
-
```python
|
14
|
-
from myldiscovery import autodiscover
|
15
|
-
autodiscover("me@example.com")
|
16
|
-
# {'imap': {'server': 'mail.example.com', 'port': 993, 'starttls': False},
|
17
|
-
# 'smtp': {'server': 'mail.example.com', 'port': 587, 'starttls': False}}
|
18
|
-
```
|
19
|
-
|
20
|
-
|
21
1
|
## Development
|
22
2
|
|
23
3
|
### Autodiscovery
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: myl-discovery
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.4
|
4
4
|
Summary: email autodiscovery
|
5
5
|
Author-email: Philipp Schmitt <philipp@schmitt.co>
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
@@ -684,130 +684,92 @@ Requires-Python: >=3.8
|
|
684
684
|
Description-Content-Type: text/markdown
|
685
685
|
License-File: LICENSE
|
686
686
|
|
687
|
-
# myl-discovery
|
687
|
+
# 📩 myl-discovery
|
688
688
|
|
689
|
-
|
689
|
+
myl-discovery is a Python library designed to detect email settings of a given
|
690
|
+
email address or domain.
|
690
691
|
|
691
|
-
## Installation
|
692
|
+
## 📥 Installation
|
692
693
|
|
693
|
-
|
694
|
+
To install myl-discovery, run the following command:
|
695
|
+
|
696
|
+
```bash
|
694
697
|
pip install myl-discovery
|
695
698
|
```
|
696
699
|
|
697
|
-
## Usage
|
700
|
+
## 📖 Usage
|
701
|
+
|
702
|
+
After installing the package, you can use the `autodiscover` function to
|
703
|
+
discover the email settings for a domain. Here's an example:
|
698
704
|
|
699
705
|
```python
|
700
706
|
from myldiscovery import autodiscover
|
701
|
-
autodiscover("me@example.com")
|
702
|
-
# {'imap': {'server': 'mail.example.com', 'port': 993, 'starttls': False},
|
703
|
-
# 'smtp': {'server': 'mail.example.com', 'port': 587, 'starttls': False}}
|
704
|
-
```
|
705
|
-
|
706
707
|
|
707
|
-
|
708
|
+
settings = autodiscover("yourdomain.com") # or me@yourdomain.com
|
709
|
+
print(settings)
|
708
710
|
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
711
|
+
# For Exchange autodiscovery you need to provide credentials
|
712
|
+
settings = autodiscover(
|
713
|
+
'me@yourdomain.com',
|
714
|
+
username='WORKGROUP\me',
|
715
|
+
password='mypassword1234'
|
716
|
+
)
|
715
717
|
```
|
716
718
|
|
717
|
-
|
718
|
-
|
719
|
-
```xml
|
720
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
721
|
-
<clientConfig version="1.1">
|
722
|
-
<emailProvider id="example.com">
|
723
|
-
<domain>example.com</domain>
|
719
|
+
## 📄 Output
|
724
720
|
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
<hostname>mail.example.com</hostname>
|
729
|
-
<port>143</port>
|
730
|
-
<socketType>STARTTLS</socketType>
|
731
|
-
<authentication>password-cleartext</authentication>
|
732
|
-
<username>%EMAILADDRESS%</username>
|
733
|
-
</incomingServer>
|
734
|
-
<outgoingServer type="smtp">
|
735
|
-
<hostname>mail.example.com</hostname>
|
736
|
-
<port>587</port>
|
737
|
-
<socketType>STARTTLS</socketType>
|
738
|
-
<authentication>password-cleartext</authentication>
|
739
|
-
<username>%EMAILADDRESS%</username>
|
740
|
-
</outgoingServer>
|
741
|
-
<documentation url="https://autodiscover.example.com">
|
742
|
-
<descr lang="en">Generic settings page</descr>
|
743
|
-
<descr lang="fr">Paramètres généraux</descr>
|
744
|
-
<descr lang="es">Configuraciones genéricas</descr>
|
745
|
-
<descr lang="de">Allgemeine Beschreibung der Einstellungen</descr>
|
746
|
-
<descr lang="ru">Страница общих настроек</descr>
|
747
|
-
</documentation>
|
748
|
-
</emailProvider>
|
749
|
-
</clientConfig>
|
750
|
-
```
|
721
|
+
The `autodiscover` function returns a dictionary with the detected settings.
|
722
|
+
The dictionary contains two keys, `imap` and `smtp`, each containing a
|
723
|
+
dictionary with the keys `server`, `port`, and `starttls`.
|
751
724
|
|
752
|
-
|
725
|
+
Here's an example:
|
753
726
|
|
754
|
-
```
|
755
|
-
|
727
|
+
```json
|
728
|
+
{
|
729
|
+
"imap": {
|
730
|
+
"server": "imap.yourdomain.com",
|
731
|
+
"port": 993,
|
732
|
+
"starttls": false
|
733
|
+
},
|
734
|
+
"smtp": {
|
735
|
+
"server": "smtp.yourdomain.com",
|
736
|
+
"port": 587,
|
737
|
+
"starttls": true
|
738
|
+
}
|
739
|
+
}
|
756
740
|
```
|
757
741
|
|
758
|
-
|
759
|
-
|
760
|
-
```xml
|
761
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
762
|
-
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
|
763
|
-
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
|
764
|
-
<User>
|
765
|
-
<DisplayName>example.com Email</DisplayName>
|
766
|
-
</User>
|
767
|
-
<Account>
|
768
|
-
<AccountType>email</AccountType>
|
769
|
-
<Action>settings</Action>
|
770
|
-
<ServiceHome>https://autodiscover.example.com</ServiceHome>
|
771
|
-
|
772
|
-
<Protocol>
|
773
|
-
<Type>IMAP</Type>
|
774
|
-
<TTL>1</TTL>
|
775
|
-
|
776
|
-
<Server>mail.example.com</Server>
|
777
|
-
<Port>143</Port>
|
742
|
+
## 🧩 Autodiscover Functions
|
778
743
|
|
779
|
-
|
744
|
+
myl-discovery exposes several functions to discover email settings:
|
780
745
|
|
781
|
-
|
782
|
-
|
746
|
+
- `autodiscover`: This function wraps the below function do automatically detect
|
747
|
+
the right settings. (See Autodiscover strategy for more information)
|
748
|
+
- `autodiscover_srv`: This function attempts to resolve SRV records for
|
749
|
+
the domain to discover IMAP and SMTP servers.
|
750
|
+
- `autodiscover_exchange`: This function attempts to use the Exchange
|
751
|
+
Autodiscover service to discover email settings. It requires a username and
|
752
|
+
password.
|
753
|
+
- `autodiscover_autoconfig`: This function attempts to fetch and parse an
|
754
|
+
autoconfig XML file from a URL specified in the domain's TXT records.
|
755
|
+
- `autodiscover_port_scan`: This function performs a port scan on the domain
|
756
|
+
to discover open IMAP and SMTP ports.
|
783
757
|
|
784
|
-
|
785
|
-
<Encryption>TLS</Encryption>
|
786
|
-
<AuthRequired>on</AuthRequired>
|
787
|
-
</Protocol>
|
788
|
-
</Account>
|
789
|
-
<Account>
|
790
|
-
<AccountType>email</AccountType>
|
791
|
-
<Action>settings</Action>
|
792
|
-
<ServiceHome>https://autodiscover.example.com</ServiceHome>
|
758
|
+
## 🧠 Autodiscover Strategy
|
793
759
|
|
794
|
-
|
795
|
-
|
796
|
-
<TTL>1</TTL>
|
760
|
+
The `autodiscover` function uses the following strategy to discover
|
761
|
+
email settings:
|
797
762
|
|
798
|
-
|
799
|
-
|
763
|
+
1. It first attempts to use `autodiscover_autoconfig` to discover settings
|
764
|
+
from an autoconfig/autodiscover URL specified in the domain's TXT records.
|
765
|
+
2. If that fails, it attempts to use `autodiscover_srv` to discover settings
|
766
|
+
from the domain's SRV records.
|
767
|
+
3. If that fails and a password is provided, it attempts to use
|
768
|
+
`autodiscover_exchange` to discover settings using the
|
769
|
+
Exchange Autodiscover service (only if credentials were provided)
|
770
|
+
4. If all else fails, it uses `autodiscover_port_scan` to discover settings by
|
771
|
+
performing a port scan on the domain.
|
800
772
|
|
801
|
-
|
802
|
-
|
803
|
-
<DomainRequired>on</DomainRequired>
|
804
|
-
<DomainName>example.com</DomainName>
|
805
|
-
|
806
|
-
<SPA>off</SPA>
|
807
|
-
<Encryption>TLS</Encryption>
|
808
|
-
<AuthRequired>on</AuthRequired>
|
809
|
-
</Protocol>
|
810
|
-
</Account></Response>
|
811
|
-
</Autodiscover>
|
812
|
-
```
|
773
|
+
## 📜 License
|
813
774
|
|
775
|
+
myl-discovery is licensed under the [GNU General Public License v3.0](LICENSE).
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# 📩 myl-discovery
|
2
|
+
|
3
|
+
myl-discovery is a Python library designed to detect email settings of a given
|
4
|
+
email address or domain.
|
5
|
+
|
6
|
+
## 📥 Installation
|
7
|
+
|
8
|
+
To install myl-discovery, run the following command:
|
9
|
+
|
10
|
+
```bash
|
11
|
+
pip install myl-discovery
|
12
|
+
```
|
13
|
+
|
14
|
+
## 📖 Usage
|
15
|
+
|
16
|
+
After installing the package, you can use the `autodiscover` function to
|
17
|
+
discover the email settings for a domain. Here's an example:
|
18
|
+
|
19
|
+
```python
|
20
|
+
from myldiscovery import autodiscover
|
21
|
+
|
22
|
+
settings = autodiscover("yourdomain.com") # or me@yourdomain.com
|
23
|
+
print(settings)
|
24
|
+
|
25
|
+
# For Exchange autodiscovery you need to provide credentials
|
26
|
+
settings = autodiscover(
|
27
|
+
'me@yourdomain.com',
|
28
|
+
username='WORKGROUP\me',
|
29
|
+
password='mypassword1234'
|
30
|
+
)
|
31
|
+
```
|
32
|
+
|
33
|
+
## 📄 Output
|
34
|
+
|
35
|
+
The `autodiscover` function returns a dictionary with the detected settings.
|
36
|
+
The dictionary contains two keys, `imap` and `smtp`, each containing a
|
37
|
+
dictionary with the keys `server`, `port`, and `starttls`.
|
38
|
+
|
39
|
+
Here's an example:
|
40
|
+
|
41
|
+
```json
|
42
|
+
{
|
43
|
+
"imap": {
|
44
|
+
"server": "imap.yourdomain.com",
|
45
|
+
"port": 993,
|
46
|
+
"starttls": false
|
47
|
+
},
|
48
|
+
"smtp": {
|
49
|
+
"server": "smtp.yourdomain.com",
|
50
|
+
"port": 587,
|
51
|
+
"starttls": true
|
52
|
+
}
|
53
|
+
}
|
54
|
+
```
|
55
|
+
|
56
|
+
## 🧩 Autodiscover Functions
|
57
|
+
|
58
|
+
myl-discovery exposes several functions to discover email settings:
|
59
|
+
|
60
|
+
- `autodiscover`: This function wraps the below function do automatically detect
|
61
|
+
the right settings. (See Autodiscover strategy for more information)
|
62
|
+
- `autodiscover_srv`: This function attempts to resolve SRV records for
|
63
|
+
the domain to discover IMAP and SMTP servers.
|
64
|
+
- `autodiscover_exchange`: This function attempts to use the Exchange
|
65
|
+
Autodiscover service to discover email settings. It requires a username and
|
66
|
+
password.
|
67
|
+
- `autodiscover_autoconfig`: This function attempts to fetch and parse an
|
68
|
+
autoconfig XML file from a URL specified in the domain's TXT records.
|
69
|
+
- `autodiscover_port_scan`: This function performs a port scan on the domain
|
70
|
+
to discover open IMAP and SMTP ports.
|
71
|
+
|
72
|
+
## 🧠 Autodiscover Strategy
|
73
|
+
|
74
|
+
The `autodiscover` function uses the following strategy to discover
|
75
|
+
email settings:
|
76
|
+
|
77
|
+
1. It first attempts to use `autodiscover_autoconfig` to discover settings
|
78
|
+
from an autoconfig/autodiscover URL specified in the domain's TXT records.
|
79
|
+
2. If that fails, it attempts to use `autodiscover_srv` to discover settings
|
80
|
+
from the domain's SRV records.
|
81
|
+
3. If that fails and a password is provided, it attempts to use
|
82
|
+
`autodiscover_exchange` to discover settings using the
|
83
|
+
Exchange Autodiscover service (only if credentials were provided)
|
84
|
+
4. If all else fails, it uses `autodiscover_port_scan` to discover settings by
|
85
|
+
performing a port scan on the domain.
|
86
|
+
|
87
|
+
## 📜 License
|
88
|
+
|
89
|
+
myl-discovery is licensed under the [GNU General Public License v3.0](LICENSE).
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: myl-discovery
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.4
|
4
4
|
Summary: email autodiscovery
|
5
5
|
Author-email: Philipp Schmitt <philipp@schmitt.co>
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
@@ -684,130 +684,92 @@ Requires-Python: >=3.8
|
|
684
684
|
Description-Content-Type: text/markdown
|
685
685
|
License-File: LICENSE
|
686
686
|
|
687
|
-
# myl-discovery
|
687
|
+
# 📩 myl-discovery
|
688
688
|
|
689
|
-
|
689
|
+
myl-discovery is a Python library designed to detect email settings of a given
|
690
|
+
email address or domain.
|
690
691
|
|
691
|
-
## Installation
|
692
|
+
## 📥 Installation
|
692
693
|
|
693
|
-
|
694
|
+
To install myl-discovery, run the following command:
|
695
|
+
|
696
|
+
```bash
|
694
697
|
pip install myl-discovery
|
695
698
|
```
|
696
699
|
|
697
|
-
## Usage
|
700
|
+
## 📖 Usage
|
701
|
+
|
702
|
+
After installing the package, you can use the `autodiscover` function to
|
703
|
+
discover the email settings for a domain. Here's an example:
|
698
704
|
|
699
705
|
```python
|
700
706
|
from myldiscovery import autodiscover
|
701
|
-
autodiscover("me@example.com")
|
702
|
-
# {'imap': {'server': 'mail.example.com', 'port': 993, 'starttls': False},
|
703
|
-
# 'smtp': {'server': 'mail.example.com', 'port': 587, 'starttls': False}}
|
704
|
-
```
|
705
|
-
|
706
707
|
|
707
|
-
|
708
|
+
settings = autodiscover("yourdomain.com") # or me@yourdomain.com
|
709
|
+
print(settings)
|
708
710
|
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
711
|
+
# For Exchange autodiscovery you need to provide credentials
|
712
|
+
settings = autodiscover(
|
713
|
+
'me@yourdomain.com',
|
714
|
+
username='WORKGROUP\me',
|
715
|
+
password='mypassword1234'
|
716
|
+
)
|
715
717
|
```
|
716
718
|
|
717
|
-
|
718
|
-
|
719
|
-
```xml
|
720
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
721
|
-
<clientConfig version="1.1">
|
722
|
-
<emailProvider id="example.com">
|
723
|
-
<domain>example.com</domain>
|
719
|
+
## 📄 Output
|
724
720
|
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
<hostname>mail.example.com</hostname>
|
729
|
-
<port>143</port>
|
730
|
-
<socketType>STARTTLS</socketType>
|
731
|
-
<authentication>password-cleartext</authentication>
|
732
|
-
<username>%EMAILADDRESS%</username>
|
733
|
-
</incomingServer>
|
734
|
-
<outgoingServer type="smtp">
|
735
|
-
<hostname>mail.example.com</hostname>
|
736
|
-
<port>587</port>
|
737
|
-
<socketType>STARTTLS</socketType>
|
738
|
-
<authentication>password-cleartext</authentication>
|
739
|
-
<username>%EMAILADDRESS%</username>
|
740
|
-
</outgoingServer>
|
741
|
-
<documentation url="https://autodiscover.example.com">
|
742
|
-
<descr lang="en">Generic settings page</descr>
|
743
|
-
<descr lang="fr">Paramètres généraux</descr>
|
744
|
-
<descr lang="es">Configuraciones genéricas</descr>
|
745
|
-
<descr lang="de">Allgemeine Beschreibung der Einstellungen</descr>
|
746
|
-
<descr lang="ru">Страница общих настроек</descr>
|
747
|
-
</documentation>
|
748
|
-
</emailProvider>
|
749
|
-
</clientConfig>
|
750
|
-
```
|
721
|
+
The `autodiscover` function returns a dictionary with the detected settings.
|
722
|
+
The dictionary contains two keys, `imap` and `smtp`, each containing a
|
723
|
+
dictionary with the keys `server`, `port`, and `starttls`.
|
751
724
|
|
752
|
-
|
725
|
+
Here's an example:
|
753
726
|
|
754
|
-
```
|
755
|
-
|
727
|
+
```json
|
728
|
+
{
|
729
|
+
"imap": {
|
730
|
+
"server": "imap.yourdomain.com",
|
731
|
+
"port": 993,
|
732
|
+
"starttls": false
|
733
|
+
},
|
734
|
+
"smtp": {
|
735
|
+
"server": "smtp.yourdomain.com",
|
736
|
+
"port": 587,
|
737
|
+
"starttls": true
|
738
|
+
}
|
739
|
+
}
|
756
740
|
```
|
757
741
|
|
758
|
-
|
759
|
-
|
760
|
-
```xml
|
761
|
-
<?xml version="1.0" encoding="utf-8" ?>
|
762
|
-
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
|
763
|
-
<Response xmlns="http://schemas.microsoft.com/exchange/autodiscover/responseschema/2006">
|
764
|
-
<User>
|
765
|
-
<DisplayName>example.com Email</DisplayName>
|
766
|
-
</User>
|
767
|
-
<Account>
|
768
|
-
<AccountType>email</AccountType>
|
769
|
-
<Action>settings</Action>
|
770
|
-
<ServiceHome>https://autodiscover.example.com</ServiceHome>
|
771
|
-
|
772
|
-
<Protocol>
|
773
|
-
<Type>IMAP</Type>
|
774
|
-
<TTL>1</TTL>
|
775
|
-
|
776
|
-
<Server>mail.example.com</Server>
|
777
|
-
<Port>143</Port>
|
742
|
+
## 🧩 Autodiscover Functions
|
778
743
|
|
779
|
-
|
744
|
+
myl-discovery exposes several functions to discover email settings:
|
780
745
|
|
781
|
-
|
782
|
-
|
746
|
+
- `autodiscover`: This function wraps the below function do automatically detect
|
747
|
+
the right settings. (See Autodiscover strategy for more information)
|
748
|
+
- `autodiscover_srv`: This function attempts to resolve SRV records for
|
749
|
+
the domain to discover IMAP and SMTP servers.
|
750
|
+
- `autodiscover_exchange`: This function attempts to use the Exchange
|
751
|
+
Autodiscover service to discover email settings. It requires a username and
|
752
|
+
password.
|
753
|
+
- `autodiscover_autoconfig`: This function attempts to fetch and parse an
|
754
|
+
autoconfig XML file from a URL specified in the domain's TXT records.
|
755
|
+
- `autodiscover_port_scan`: This function performs a port scan on the domain
|
756
|
+
to discover open IMAP and SMTP ports.
|
783
757
|
|
784
|
-
|
785
|
-
<Encryption>TLS</Encryption>
|
786
|
-
<AuthRequired>on</AuthRequired>
|
787
|
-
</Protocol>
|
788
|
-
</Account>
|
789
|
-
<Account>
|
790
|
-
<AccountType>email</AccountType>
|
791
|
-
<Action>settings</Action>
|
792
|
-
<ServiceHome>https://autodiscover.example.com</ServiceHome>
|
758
|
+
## 🧠 Autodiscover Strategy
|
793
759
|
|
794
|
-
|
795
|
-
|
796
|
-
<TTL>1</TTL>
|
760
|
+
The `autodiscover` function uses the following strategy to discover
|
761
|
+
email settings:
|
797
762
|
|
798
|
-
|
799
|
-
|
763
|
+
1. It first attempts to use `autodiscover_autoconfig` to discover settings
|
764
|
+
from an autoconfig/autodiscover URL specified in the domain's TXT records.
|
765
|
+
2. If that fails, it attempts to use `autodiscover_srv` to discover settings
|
766
|
+
from the domain's SRV records.
|
767
|
+
3. If that fails and a password is provided, it attempts to use
|
768
|
+
`autodiscover_exchange` to discover settings using the
|
769
|
+
Exchange Autodiscover service (only if credentials were provided)
|
770
|
+
4. If all else fails, it uses `autodiscover_port_scan` to discover settings by
|
771
|
+
performing a port scan on the domain.
|
800
772
|
|
801
|
-
|
802
|
-
|
803
|
-
<DomainRequired>on</DomainRequired>
|
804
|
-
<DomainName>example.com</DomainName>
|
805
|
-
|
806
|
-
<SPA>off</SPA>
|
807
|
-
<Encryption>TLS</Encryption>
|
808
|
-
<AuthRequired>on</AuthRequired>
|
809
|
-
</Protocol>
|
810
|
-
</Account></Response>
|
811
|
-
</Autodiscover>
|
812
|
-
```
|
773
|
+
## 📜 License
|
813
774
|
|
775
|
+
myl-discovery is licensed under the [GNU General Public License v3.0](LICENSE).
|
@@ -0,0 +1,19 @@
|
|
1
|
+
from .discovery import (
|
2
|
+
autodiscover,
|
3
|
+
autodiscover_autoconfig,
|
4
|
+
autodiscover_exchange,
|
5
|
+
autodiscover_port_scan,
|
6
|
+
autodiscover_srv,
|
7
|
+
autodiscover_txt,
|
8
|
+
)
|
9
|
+
from .main import main
|
10
|
+
|
11
|
+
__all__ = [
|
12
|
+
"main",
|
13
|
+
"autodiscover",
|
14
|
+
"autodiscover_autoconfig",
|
15
|
+
"autodiscover_exchange",
|
16
|
+
"autodiscover_port_scan",
|
17
|
+
"autodiscover_srv",
|
18
|
+
"autodiscover_txt",
|
19
|
+
]
|
@@ -66,10 +66,13 @@ def resolve_srv(domain):
|
|
66
66
|
|
67
67
|
|
68
68
|
def autodiscover_txt(domain):
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
try:
|
70
|
+
res = resolve_txt(domain, criteria="^mailconf=")
|
71
|
+
if not res:
|
72
|
+
return
|
73
|
+
return res.split("=")[1]
|
74
|
+
except Exception:
|
75
|
+
LOGGER.warning("Failed to resolve TXT record")
|
73
76
|
|
74
77
|
|
75
78
|
def parse_autoconfig(content):
|
@@ -147,29 +150,35 @@ def parse_autodiscover(content):
|
|
147
150
|
|
148
151
|
|
149
152
|
def autodiscover_srv(domain):
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
153
|
+
try:
|
154
|
+
imap = resolve_srv(f"_imaps._tcp.{domain}")
|
155
|
+
smtp = resolve_srv(f"_submission._tcp.{domain}")
|
156
|
+
|
157
|
+
assert imap is not None
|
158
|
+
assert smtp is not None
|
159
|
+
|
160
|
+
return {
|
161
|
+
"imap": {
|
162
|
+
"server": imap[0].get("hostname"),
|
163
|
+
"port": int(imap[0].get("port")),
|
164
|
+
# FIXME We might want to "smartly" guess if starttls should be
|
165
|
+
# enabled or not, depending on the port:
|
166
|
+
# 143 -> starttls
|
167
|
+
# 993 -> no
|
168
|
+
"starttls": False,
|
169
|
+
},
|
170
|
+
"smtp": {
|
171
|
+
"server": smtp[0].get("hostname"),
|
172
|
+
"port": int(smtp[0].get("port")),
|
173
|
+
# FIXME We might want to "smartly" guess if starttls should be
|
174
|
+
# enabled or not, depending on the port:
|
175
|
+
# 465 -> starttls
|
176
|
+
# 587 -> no
|
177
|
+
"starttls": False,
|
178
|
+
},
|
179
|
+
}
|
180
|
+
except Exception as e:
|
181
|
+
LOGGER.warning(f"Failed to resolve SRV records: {e}")
|
173
182
|
|
174
183
|
|
175
184
|
def port_check(host, port):
|
@@ -187,14 +196,19 @@ def check_email_ports(host):
|
|
187
196
|
|
188
197
|
|
189
198
|
def autodiscover_exchange(email, password, username=None):
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
199
|
+
try:
|
200
|
+
if not username:
|
201
|
+
username = email
|
202
|
+
creds = Credentials(username=username, password=password)
|
203
|
+
account = Account(
|
204
|
+
primary_smtp_address=email, credentials=creds, autodiscover=True
|
205
|
+
)
|
206
|
+
return autodiscover_port_scan(account.protocol.server)
|
207
|
+
except Exception as e:
|
208
|
+
LOGGER.warning(f"Failed to autodiscover Exchange: {e}")
|
209
|
+
|
210
|
+
|
211
|
+
def autodiscover_port_scan(server):
|
198
212
|
portscan = check_email_ports(server)
|
199
213
|
LOGGER.info(f"Port scan results: {portscan}")
|
200
214
|
|
@@ -228,27 +242,12 @@ def autodiscover_exchange(email, password, username=None):
|
|
228
242
|
}
|
229
243
|
|
230
244
|
|
231
|
-
def
|
232
|
-
domain = email_addr.split("@")[-1]
|
233
|
-
if not domain:
|
234
|
-
raise ValueError(f"Invalid email address {email_addr}")
|
235
|
-
|
236
|
-
if srv_only:
|
237
|
-
return autodiscover_srv(domain)
|
238
|
-
|
245
|
+
def autodiscover_autoconfig(domain):
|
239
246
|
autoconfig = autodiscover_txt(domain)
|
240
247
|
|
241
248
|
if not autoconfig:
|
242
|
-
|
243
|
-
|
244
|
-
except Exception:
|
245
|
-
LOGGER.warning("Failed to autodiscover using SRV records")
|
246
|
-
if password:
|
247
|
-
LOGGER.info("Trying autodiscover using Exchange credentials")
|
248
|
-
return autodiscover_exchange(
|
249
|
-
email=email_addr, username=username, password=password
|
250
|
-
)
|
251
|
-
return
|
249
|
+
LOGGER.warning("Failed to autodiscover using TXT records")
|
250
|
+
return
|
252
251
|
|
253
252
|
res = requests.get(autoconfig)
|
254
253
|
res.raise_for_status()
|
@@ -258,3 +257,25 @@ def autodiscover(email_addr, srv_only=False, username=None, password=None):
|
|
258
257
|
except Exception:
|
259
258
|
LOGGER.warning("Failed to parse autoconfig, trying autodiscover")
|
260
259
|
return parse_autodiscover(res.text)
|
260
|
+
|
261
|
+
|
262
|
+
def autodiscover(email_addr, username=None, password=None):
|
263
|
+
domain = email_addr.split("@")[-1]
|
264
|
+
if not domain:
|
265
|
+
raise ValueError(f"Invalid email address {email_addr}")
|
266
|
+
|
267
|
+
res = autodiscover_autoconfig(domain)
|
268
|
+
|
269
|
+
if not res:
|
270
|
+
res = autodiscover_srv(domain)
|
271
|
+
|
272
|
+
if not res and password:
|
273
|
+
res = autodiscover_srv(domain)
|
274
|
+
autodiscover_exchange(
|
275
|
+
email=email_addr, username=username, password=password
|
276
|
+
)
|
277
|
+
|
278
|
+
if not res:
|
279
|
+
res = autodiscover_port_scan(domain)
|
280
|
+
|
281
|
+
return res
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|