Parcourir la source

add cc + bcc + default function parameters for sendStarttls() python mailfunction

Noah Vogt il y a 3 ans
Parent
commit
32395bbc8d
1 fichiers modifiés avec 3 ajouts et 2 suppressions
  1. 3 2
      app/src/main/python/mailFunctions.py

+ 3 - 2
app/src/main/python/mailFunctions.py

@@ -93,9 +93,10 @@ def fetchMails(connection, inbox):
 
     return output_list
 
-def sendStarttls(host, sendingMail, receivingMail, password, message, subject, port):
+def sendStarttls(host, sendingMail, receivingMail, password, message="", subject="", port=587, cc=[], bcc=[]):
     context = ssl.create_default_context()
-    utf8Message = "Subject: " + subject + "\n\n" + message
+
+    utf8Message = "Subject: " + subject + "\nCC: " + ",".join(cc) + "\nBCC: " + ",".join(bcc) + "\n\n" + message
     decoded=utf8Message.encode('cp1252').decode('utf-8')
 
     with smtplib.SMTP(host, port) as serverConnection: