ksa / smtp.py
admin
upd req
3f6932f
raw
history blame
1.05 kB
import requests
from config import *
def send_email(
content,
title="Runtime error detected",
header="Please fix following repo(s):",
email=EMAIL,
password=SMTP,
target=TAG,
host=HOST,
port=PORT,
):
body = f"""
<html>
<body>
<h2>{header}</h2>
{content}
</body>
</html>
"""
response = requests.get(
API,
params={
"host": host,
"Port": port,
"key": password, # apikey
"email": email, # from
"mail": target, # to
"title": title, # subject
"name": "ksa", # nickname
"text": body, # content
},
)
if response.status_code == 200:
result: dict = response.json()
if result.get("status") == "success":
print("Email sent successfully!")
else:
print(f"Failed to send email: {result.get('message')}")
else:
print(f"Request failed with status code: {response.status_code}")