Skip to Main Content
Python Network Programming
book

Python Network Programming

by Abhishek Ratan, Eric Chou, Pradeeban Kathiravelu, Dr. M. O. Faruque Sarker
January 2019
Beginner to intermediate content levelBeginner to intermediate
776 pages
19h 58m
English
Packt Publishing
Content preview from Python Network Programming

How to do it...

The server receives the messages from the clients and logs them to the console.

Listing 5.9a gives the code for the SMTP server 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 smtplib import email.utils import argparse from email.mime.text import MIMEText def mail_client(host, port, fromAddress, toAddress, subject, body): msg = MIMEText(body) msg['To'] = email.utils.formataddr(('Recipient', toAddress)) msg['From'] = email.utils.formataddr(('Author', fromAddress)) msg['Subject'] = subject server = smtplib.SMTP(host, port) server.set_debuglevel(True) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Network Programming for Network Engineers (Python 3)

Python Network Programming for Network Engineers (Python 3)

David Bombal

Publisher Resources

ISBN: 9781788835466Supplemental Content