Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed attachment issue #7

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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