Skip to content

Commit

Permalink
💩 started writing the mail framework... not working yet.. -_-
Browse files Browse the repository at this point in the history
  • Loading branch information
pheeef committed Sep 15, 2020
1 parent 05c6c43 commit 2742ba8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions assets/mail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import smtplib
from socket import gaierror


def sendMail(to: str, subject: str, message: str):
import env as e
try:
with smtplib.SMTP(e.mail_host, e.mail_port) as server:
server.login(e.mail_username, e.mail_password)
server.sendmail(from_addr=e.mail_sender, to_addrs=to, msg=message)
except (gaierror, ConnectionRefusedError):
return "failed to connect to the server"
except smtplib.SMTPServerDisconnected:
return "Failed to connect to the server with the given credentials"
except smtplib.SMTPException as e:
return "SMTP error occured: " + str(e)
server.close()
return True

0 comments on commit 2742ba8

Please sign in to comment.