Skip to content

Commit

Permalink
update email.py with new mail server quick fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan3232 committed Jan 26, 2024
1 parent f46f022 commit 649333c
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/email.py
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

Expand Down Expand Up @@ -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")]
Expand All @@ -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)


0 comments on commit 649333c

Please sign in to comment.