Last active
June 13, 2021 11:27
-
-
Save a9QrX3Lu/7873552558e350d9405f989087266028 to your computer and use it in GitHub Desktop.
Notification for a finished long-running job
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| SERVER = "smtp.office365.com" | |
| PORT = "587" | |
| FROM = "wzl574402791@outlook.com" | |
| TO = ["zl31wang@gmail.com"] | |
| SUBJECT = "A job finished" | |
| TEXT = "Hi! A job finished. Please take a look." | |
| message = """From: %s\r\nTo: %s\r\nSubject: %s\r\n\ | |
| %s | |
| """ % (FROM, ", ".join(TO), SUBJECT, TEXT) | |
| import smtplib | |
| from pathlib import Path | |
| server = smtplib.SMTP(SERVER, PORT) | |
| with open(f'{Path.home()}/.outlook', 'r') as f: | |
| code = f.readline() | |
| server.starttls() | |
| server.login(FROM, code) | |
| server.sendmail(FROM, TO, message) | |
| server.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment