-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmailer_functions.py
47 lines (39 loc) · 1.71 KB
/
mailer_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from typing import List, Tuple
from smtplib import SMTP
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
smtp = SMTP("mail.asap-it.tech", port=465)
def send_verification_link(verification_link: str, email: str, name: str):
text = f"""From: ASAP NEWS <[email protected]>
To: {name}<{email}>
Subject: Подтвердите свой Email
Перейдите по ссылке для подтверждения почты: {verification_link}"""
smtp.connect(host="151.248.123.101", port=465)
print(smtp.sendmail("[email protected]", email, text.encode("utf-8")))
smtp.close()
# subject = "Науменко - проректор по развитию"
# text = f"""From: ASAP NEWS<[email protected]>
# To: TEST MAIL<[email protected]>
# Subject: "email verification"
#
# Перейдите по ссылке для подтверждения почты /link/"""
#
# smtp.connect(host="151.248.123.101", port=465)
# print(smtp.sendmail("[email protected]", "[email protected]", text.encode("utf-8")))
# smtp.close()
def send_briefs(emails: List[Tuple[str, str]], briefes: str):
smtp.connect(host="151.248.123.101", port=465)
for email_name in emails:
text = f"""Посомтрите на наши очешуенные новости!<br/>
{briefes}
"""
message = MIMEMultipart("alternative")
message["Subject"] = "New News"
message["From"] = "[email protected]"
message["To"] = email_name[0]
message.attach(MIMEText(text, "html"))
print(message.as_string())
smtp.sendmail(
"[email protected]", [email_name[0]], message.as_string()
)
smtp.close()