Page MenuHomePhabricator
Paste P15864

generate_mbox.py
ActivePublic

Authored by Legoktm on May 8 2021, 1:36 AM.
Tags
None
Referenced Files
F34445767: generate_mbox.py
May 8 2021, 1:36 AM
Subscribers
None
#!/usr/bin/env python3
from email.message import EmailMessage
import mailbox
def main():
path = "/home/km/tmp/test.mbox"
mbox = mailbox.mbox(path, create=True)
count = 0
while count < 1000000:
msg = EmailMessage()
msg['Subject'] = f"Test email #{count}"
msg['From'] = "test@example.org"
msg["To"] = "test5@polymorphic.lists.wmcloud.org"
msg.set_content("blah blah blah " * 100)
mbox.add(msg)
count += 1
mbox.close()
if __name__ == "__main__":
main()