A mirror of dcurooms found at https://github.com/theycallmemac/dcurooms
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

48 Zeilen
1.5 KiB

  1. import sys
  2. import smtplib
  3. __author__ = "theycallmemac"
  4. __version__ = '2.0.0'
  5. __copyright__ = 'Copyright (c) 2018 theycallmemac'
  6. __license__ = 'GPL-3.0'
  7. class LabBooking(object):
  8. arguments = []
  9. email= ""
  10. password = ""
  11. name = ""
  12. society = ""
  13. def __init__(self, email, password, name, society, arguments):
  14. self.arguments = arguments
  15. self.email = email
  16. self.password = password
  17. self.name = name
  18. self.society = society
  19. def draft(self):
  20. FROM = self.email
  21. TO = ['irene.mcevoy@dcu.ie']
  22. SUBJECT = 'Lab Booking'
  23. BODY = "Just wondering if you could book " + self.arguments[0] + " on the " + \
  24. self.arguments[1] + " from " + self.arguments[2][:2] + ":" + \
  25. self.arguments[2][2:] + " to " + self.arguments[3][:2] + ":" + \
  26. self.arguments[3][2:] + " for " + self.society + ".\n\nThank you,\n" + self.name + "."
  27. message = """From: %s\nTo: %s\nSubject: %s\n\n%s""" % (FROM, ", ".join(TO), SUBJECT, BODY)
  28. return (FROM, TO), message
  29. def send(self, FROM, TO, message):
  30. try:
  31. server = smtplib.SMTP("smtp.gmail.com", 587)
  32. server.ehlo()
  33. server.starttls()
  34. server.login(self.email, self.password)
  35. server.sendmail(FROM, TO, message)
  36. server.close()
  37. print("Your email has been sent.")
  38. except BaseException:
  39. print("Email failed to send.")