-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавил уведомления на почту при регистрации
- Loading branch information
Showing
4 changed files
with
38 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
import asyncio | ||
import smtplib | ||
from email.mime.text import MIMEText | ||
from email.mime.multipart import MIMEMultipart | ||
|
||
from src.config import MAIL_LOGIN, MAIL_PWD | ||
|
||
|
||
async def check_dict(result): | ||
if result: | ||
return dict(result) | ||
return None | ||
|
||
|
||
async def send_mail(to_addr: str, subject: str, msg: str): | ||
multipart_msg = MIMEMultipart() | ||
multipart_msg['From'] = MAIL_LOGIN | ||
multipart_msg['To'] = to_addr | ||
multipart_msg['Subject'] = subject | ||
multipart_msg.attach(MIMEText(msg, 'plain')) | ||
|
||
smtp_obj = smtplib.SMTP('smtp.gmail.com', 587) | ||
smtp_obj.starttls() | ||
smtp_obj.login(MAIL_LOGIN, MAIL_PWD) | ||
smtp_obj.send_message(multipart_msg) | ||
smtp_obj.quit() | ||
print("письмо отправлено") | ||
|
||
if __name__ == '__main__': | ||
print("Hello") | ||
asyncio.run(send_mail("[email protected]", "HELLO", "Hello Hello")) |