Skip to content

Commit

Permalink
Merge pull request #7 from ethereum/fredriksvantes-patch-1
Browse files Browse the repository at this point in the history
Fixed attachment issue
  • Loading branch information
fredriksvantes committed Sep 2, 2024
2 parents b950ffd + 9eac819 commit 8177739
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,23 +78,26 @@ def create_email(to_email, identifier, text, all_attachments):
"""
plain_text = text.replace('<br />', '\n')
message = Mail(
from_email=FROMEMAIL,
to_emails=to_email,
subject=f'Secure Form Submission {identifier}',
plain_text_content=plain_text
)
from_email=FROMEMAIL,
to_emails=to_email,
subject=f'Secure Form Submission {identifier}',
plain_text_content=plain_text)

for item in all_attachments:
filename = item['filename']
attachment = item['attachment']

for filename, attachment in all_attachments:
encoded_file = base64.b64encode(attachment.encode("utf-8")).decode()
attached_file = Attachment(
attachedFile = Attachment(
FileContent(encoded_file),
FileName(filename + '.pgp'),
FileType('application/pgp-encrypted'),
Disposition('attachment')
)
message.add_attachment(attached_file)
message.add_attachment(attachedFile)
return message


def validate_recaptcha(recaptcha_response):
"""
Validates the ReCaptcha response.
Expand Down

0 comments on commit 8177739

Please sign in to comment.