1234567891011121314151617 |
- def sendStarttls(host, sendingMail, receivingMail, password, message="",
- subject="", port=587, cc=[], bcc=[]):
- context = ssl.create_default_context()
- if type(cc) is not str:
- cc = ",".join(cc)
- if type(bcc) is not str:
- bcc = ",".join(bcc)
- utf8Message = ("Subject: " + subject + "\nCC: " + cc + "\nBCC: " + bcc +
- "\n\n" + message)
- decoded = utf8Message.encode('cp1252').decode('utf-8')
- with smtplib.SMTP(host, port) as serverConnection:
- serverConnection.starttls(context=context)
- serverConnection.login(sendingMail, password)
- serverConnection.sendmail(sendingMail, receivingMail, decoded)
|