Skip to content

Commit

Permalink
init + get email send working
Browse files Browse the repository at this point in the history
  • Loading branch information
bertwagner committed Oct 3, 2020
1 parent 232f330 commit be1b5df
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv/
.vscode/
38 changes: 38 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import smtplib
import os

def GetLog():
pass

def FilterUninteresting404s():
pass

def SendEmail():
FROM = os.environ["apache_404_monitor_email_from"]
TO = [os.environ["apache_404_monitor_email_to"]]
SUBJECT = 'test subject!'
TEXT = 'this is the body of hte message!'

message = """From: %s\nTo: %s\nSubject: %s\n\n%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)

server = smtplib.SMTP("smtp.gmail.com", 587)
server.ehlo()
server.starttls()
server.login(FROM, os.environ["apache_404_monitor_password"])
server.sendmail(FROM, TO, message)
server.close()
print('successfully sent the mail')


if __name__ == "__main__":

# Need to set 3 environment variables before running
# apache_404_monitor_email_from
# apache_404_monitor_email_password
# apache_404_monitor_email_to

GetLog()
FilterUninteresting404s()
SendEmail()

Binary file added requirements.txt
Binary file not shown.

0 comments on commit be1b5df

Please sign in to comment.