Created
March 20, 2019 20:27
-
-
Save mgnisia/c8efb84d730a51b64d78439b35c8ea6e to your computer and use it in GitHub Desktop.
Recovering Emails Django Mailbox https://github.com/coddingtonbear/django-mailbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creating Function to write Email as EML File to Disk | |
def save_message(message_admin, request, queryset): | |
i = 0 | |
for message in queryset.all(): | |
eml_content = message.get_email_object().as_bytes() | |
file_name = f"some_file_path/{message.subject}_{i}.eml" | |
print(file_name) | |
with open(file_name, "wb") as outfile: | |
outfile.write(eml_content) | |
i += 1 | |
# Registering the save_message Command in the Admin panel | |
actions = [resend_message_received_signal, save_message] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment