-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update email.py with new mail server quick fix
- Loading branch information
1 parent
f46f022
commit 649333c
Showing
1 changed file
with
22 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
import smtplib | ||
import ssl | ||
from datetime import datetime, timedelta | ||
from typing import List | ||
|
||
|
@@ -99,7 +101,7 @@ def fmt_date(dt: datetime): | |
body=body, | ||
) | ||
|
||
def send(self) -> None: | ||
def OLDsend(self) -> None: | ||
# TODO: When 162 adds HTML support, bring back HTML emails. | ||
# html_body = Markdown().convert(self.body) | ||
# extra_headers = [("Content-Type", "text/html; charset=UTF-8")] | ||
|
@@ -125,3 +127,22 @@ def send(self) -> None: | |
|
||
except Exception as e: | ||
raise EmailError("An error occurred while sending an email:", e) | ||
|
||
|
||
def send(self) -> None: | ||
port = 587 # For starttls | ||
smtp_server = "email-smtp.us-west-2.amazonaws.com" | ||
sender_email = "[email protected]" | ||
receiver_email = "[email protected]" | ||
password = "BHhdBFBMXzxkzc/mVOKxgnlUtPJPWuShq3UoHhaOoicg" | ||
message = self.body | ||
|
||
context = ssl.create_default_context() | ||
with smtplib.SMTP(smtp_server, port) as server: | ||
server.ehlo() # Can be omitted | ||
server.starttls(context=context) | ||
server.ehlo() # Can be omitted | ||
server.login("AKIA6JV7O2DSO5LAKD6I", password) | ||
server.sendmail(sender_email, receiver_email, message) | ||
|
||
|