Преглед на файлове

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

Noah Vogt преди 3 години
родител
ревизия
32395bbc8d
променени са 1 файла, в които са добавени 3 реда и са изтрити 2 реда
  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: