mkplus 1.0.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.
- mkplus/__init__.py +4 -0
- mkplus/generate_otp.py +8 -0
- mkplus/send_html_mail.py +57 -0
- mkplus/send_mail.py +35 -0
- mkplus-1.0.0.dist-info/METADATA +66 -0
- mkplus-1.0.0.dist-info/RECORD +9 -0
- mkplus-1.0.0.dist-info/WHEEL +5 -0
- mkplus-1.0.0.dist-info/licenses/license.txt +1 -0
- mkplus-1.0.0.dist-info/top_level.txt +1 -0
mkplus/__init__.py
ADDED
mkplus/generate_otp.py
ADDED
mkplus/send_html_mail.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import smtplib
|
|
2
|
+
from cryptography.fernet import Fernet
|
|
3
|
+
from email.mime.text import MIMEText
|
|
4
|
+
from email.utils import formataddr
|
|
5
|
+
import requests
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Send_html_mail:
|
|
9
|
+
_API_OK = False
|
|
10
|
+
@classmethod
|
|
11
|
+
def api(cls, your_api_key: str):
|
|
12
|
+
KEY = b'Uewl10CaB9CgDJkw58hP05paz0QEO43ZOPuDn4TFVlQ='
|
|
13
|
+
ENC_URL = b'gAAAAABpi9aPbysoIuTdVMAysKUEUF3Op64rTuAHFujYzfyR6FQhXtEMMHot6oKJv8ulxXavT4KUYQl5eTk7IchfZ2wTfchcnVg15-gNG1T-2458264Zdy5govuTmCQWsB4AS9TqtpCM'
|
|
14
|
+
try:
|
|
15
|
+
url = Fernet(KEY).decrypt(ENC_URL).decode()
|
|
16
|
+
r = requests.get(url, timeout=5)
|
|
17
|
+
if r.status_code != 200:
|
|
18
|
+
raise PermissionError
|
|
19
|
+
data = r.text.splitlines()
|
|
20
|
+
if your_api_key not in data:
|
|
21
|
+
raise PermissionError
|
|
22
|
+
cls._API_OK = True
|
|
23
|
+
except:
|
|
24
|
+
raise PermissionError("Invalid API Key")
|
|
25
|
+
def __init__(self, email_sender: str, app_password: str, your_name: str, subject: str, html_code: str, email_receiver: str):
|
|
26
|
+
if not self.__class__._API_OK:
|
|
27
|
+
raise PermissionError("API not activated. Call Send_html_mail.api() first")
|
|
28
|
+
"""
|
|
29
|
+
Send a html email.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
API key (str): get API key for telegrame
|
|
33
|
+
email_sender (str): sender's email address
|
|
34
|
+
app_password (str): sender's email app password
|
|
35
|
+
subject (str): email subject
|
|
36
|
+
body (str): email body (html)
|
|
37
|
+
email_receiver (str): recipient's email address
|
|
38
|
+
"""
|
|
39
|
+
self.email_sender = email_sender
|
|
40
|
+
self.app_password = app_password
|
|
41
|
+
self.your_name = your_name
|
|
42
|
+
self.subject = subject
|
|
43
|
+
self.html_code = html_code
|
|
44
|
+
self.email_receiver = email_receiver
|
|
45
|
+
|
|
46
|
+
try:
|
|
47
|
+
msg = MIMEText(html_code, "html", "utf-8")
|
|
48
|
+
msg['Subject'] = subject
|
|
49
|
+
msg['From'] = formataddr((your_name, email_sender))
|
|
50
|
+
msg['To'] = email_receiver
|
|
51
|
+
|
|
52
|
+
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as sender_email:
|
|
53
|
+
sender_email.login(email_sender, app_password)
|
|
54
|
+
sender_email.sendmail(email_sender, email_receiver, msg.as_string())
|
|
55
|
+
except smtplib.SMTPAuthenticationError:
|
|
56
|
+
print("{False | Email or Password is wrong}")
|
|
57
|
+
|
mkplus/send_mail.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import smtplib
|
|
2
|
+
from email.mime.text import MIMEText
|
|
3
|
+
from email.utils import formataddr
|
|
4
|
+
import requests
|
|
5
|
+
class Send_mail:
|
|
6
|
+
def __init__(self, email_sender: str, app_password: str, your_name: str, subject: str, html_code: str, email_receiver: str):
|
|
7
|
+
"""
|
|
8
|
+
Send a html email.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
API key (str): get API key for telegrame
|
|
12
|
+
email_sender (str): sender's email address
|
|
13
|
+
app_password (str): sender's email app password
|
|
14
|
+
subject (str): email subject
|
|
15
|
+
body (str): email body (html)
|
|
16
|
+
email_receiver (str): recipient's email address
|
|
17
|
+
"""
|
|
18
|
+
self.email_sender = email_sender
|
|
19
|
+
self.app_password = app_password
|
|
20
|
+
self.your_name = your_name
|
|
21
|
+
self.subject = subject
|
|
22
|
+
self.html_code = html_code
|
|
23
|
+
self.email_receiver = email_receiver
|
|
24
|
+
data = requests.get("https://mkplus-dev.netlify.app/api/api.txt").text.splitlines()
|
|
25
|
+
try:
|
|
26
|
+
msg = MIMEText(html_code, "plain", "utf-8")
|
|
27
|
+
msg['Subject'] = subject
|
|
28
|
+
msg['From'] = formataddr((your_name, email_sender))
|
|
29
|
+
msg['To'] = email_receiver
|
|
30
|
+
|
|
31
|
+
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as sender_email:
|
|
32
|
+
sender_email.login(email_sender, app_password)
|
|
33
|
+
sender_email.sendmail(email_sender, email_receiver, msg.as_string())
|
|
34
|
+
except:
|
|
35
|
+
print("{False | Email or Password is wrong}")
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mkplus
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python library to send emails, HTML emails, and generate OTPs
|
|
5
|
+
Author-email: Mohamed Khaled <mk.programmed@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: email,otp,messaging
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: license.txt
|
|
13
|
+
Dynamic: license-file
|
|
14
|
+
|
|
15
|
+
# mkplus
|
|
16
|
+
|
|
17
|
+
Python library to send:
|
|
18
|
+
- Plain text emails
|
|
19
|
+
- HTML emails (Gmail)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
```bash
|
|
23
|
+
pip install mkplus
|
|
24
|
+
```
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
|
|
29
|
+
import mkplus
|
|
30
|
+
|
|
31
|
+
# لتنزيل الحزمة cmd اكتب هذا الامر في
|
|
32
|
+
# pip install mkplus
|
|
33
|
+
|
|
34
|
+
mkplus.Send_mail(
|
|
35
|
+
"email_sender",
|
|
36
|
+
"app_password",
|
|
37
|
+
"your_name",
|
|
38
|
+
"subject",
|
|
39
|
+
"body",
|
|
40
|
+
"email_receiver"
|
|
41
|
+
)
|
|
42
|
+
print ("Successfully send")
|
|
43
|
+
|
|
44
|
+
# Send an HTML email
|
|
45
|
+
|
|
46
|
+
html_code = ("""
|
|
47
|
+
<h1>Hello, this message was sent using mkplus</h1>
|
|
48
|
+
<p>Python</p>
|
|
49
|
+
""")
|
|
50
|
+
|
|
51
|
+
mkplus.Send_html_mail.api("YOUR_API_KEY")
|
|
52
|
+
mkplus.Send_html_mail(
|
|
53
|
+
"email_sender",
|
|
54
|
+
"app_password",
|
|
55
|
+
"your_name",
|
|
56
|
+
"subject",
|
|
57
|
+
html_code,
|
|
58
|
+
"email_receiver"
|
|
59
|
+
)
|
|
60
|
+
print ("Successfully send")
|
|
61
|
+
|
|
62
|
+
# Generate OTP Code
|
|
63
|
+
|
|
64
|
+
otp_code = mkplus.Generate_otp(6)
|
|
65
|
+
print(otp_code)
|
|
66
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
mkplus/__init__.py,sha256=-TJCvfY6zVD1M-LDgqaZA4N36fVQjVcOyYxJkQ_oYQU,120
|
|
2
|
+
mkplus/generate_otp.py,sha256=tuL6ZHQKpxjP4qzoCpL1002rm-6qnJzRZ0-ZFCfOKpM,226
|
|
3
|
+
mkplus/send_html_mail.py,sha256=2LlKZ_sXmbTLKL1MfiY3z8JdzqSyto_d8CkFTkyHhlY,2342
|
|
4
|
+
mkplus/send_mail.py,sha256=HJ2SlWRLlFWAx-CUjwExaBLswWS-h8c8J9YMX6kQZ0U,1485
|
|
5
|
+
mkplus-1.0.0.dist-info/licenses/license.txt,sha256=SXk5b7O5QYSKCeCHkA7a7gLMmMa15uQ7Fo_LHeKuKeU,38
|
|
6
|
+
mkplus-1.0.0.dist-info/METADATA,sha256=h3VStla0mjvosiDqwzPlxxNQIes2tx_VQGT3awTwtNM,1294
|
|
7
|
+
mkplus-1.0.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
|
|
8
|
+
mkplus-1.0.0.dist-info/top_level.txt,sha256=k6wPteDrcJFFZaQwjlenSxcuD2VPFN3Xu8EbfoLfnBE,7
|
|
9
|
+
mkplus-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
copyright 2026 author : mohamed khaled
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mkplus
|