Christian,
I work with Charles and have been looking into how to implement your suggestion. One thing I have figure out is how to send encrypted email within our internal email system from python. I noticed ReviewBoard utilizes djblets to send the emails. If we allow ReviewBoard to format the emails but encrypt the emails prior to sending, that will meet the requirements for data protections. I'm having trouble narrowing down where the djblets email mechanism resides and if I can extend it.
I don't find the call to the EmailMessage.send()
The code I would like to implement would be to catch the email prior to send and utilize my own code to copy over the parameters and send using the encryption logic, sample below. I don't know if the djblets would be able to handle the send if I just encrypted the text.
Thanks in advance for any suggestions you have and were to start.
Jeremy
def send_encrypted_email(smtp_server_name, user_from_email, user_to_email, email_subject, email_message):
pem_key = #... generate the key per our organizational infrastructure ...
# Create the message to encrypt
unencrypted_email = [
'To: ' + user_to_email,
'From: ' + user_from_email,
'Subject: ' + email_subject,
'',
email_message
]
# Encrypt the message
encrypted_email = smime.encrypt('\n'.join(unencrypted_email), pem_key)
# Send the message via local SMTP server.
with smtplib.SMTP(smtp_server_name) as server:
server.sendmail(user_from_email, user_to_email, encrypted_email)
server.quit()
On Tuesday, February 23, 2021 at 5:58:25 AM UTC-6 Christian Hammond wrote: