January 2019
Beginner to intermediate
776 pages
19h 58m
English
Let us first compress the current directory and then create an email message. We can send the email message via an external SMTP host, or we can use a local email server to do this. Like other recipes, let us get the sender and recipient information from parsing the command-line inputs.
Listing 5.3 shows how to convert an email folder into a compressed ZIP file as follows:
#!/usr/bin/env python # Python Network Programming Cookbook, Second Edition -- Chapter - 5 # This program is optimized for Python 2.7.12 and Python 3.5.2. # It may run on any other version with/without modifications. import os import argparse import smtplib import zipfile import tempfile from email import encoders from email.mime.base import MIMEBase from ...
Read now
Unlock full access