Python
  Home arrow Python arrow Python Email Libraries: SMTP and Email Parsing
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PYTHON

Python Email Libraries: SMTP and Email Parsing
By: Michael Swanson
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 21
    2005-09-13


    Table of Contents:
  • Python Email Libraries: SMTP and Email Parsing
  • The Python Email Library
  • Manipulating Message Objects
  • Sending Email Messages

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Python Email Libraries: SMTP and Email Parsing
    ( Page 1 of 4 )

    The previous two articles in this series discussed connecting to the two major types of email servers and downloading messages. The task yet to be discussed is the actual sending of a message and how to represent an email message logically. In the first part of this article, we will discuss how to create the local data structure to represent an email message. The second part deals with actually connecting to an SMTP server and sending the message.

    MIME Messaging

    Python’s main library for dealing with email messages is called the email library, which contains many different objects. A good portion of these objects are concerned with creating and manipulating MIME objects. MIME stands for Multipurpose Internet Mail Extensions and is the standard for formatting email messages, especially email messages that carry attachments. A full discussion of MIME is quite extensive and beyond the scope of this article; however, some familiarity with the standard is useful for understanding how MIME messages are composed.

    A MIME message is composed of many “parts,” each of which holds a separate piece of data. This data can be any number of different types, for example, it could be text, an image, a media file, or any number of other things. Most messages nowadays are classified overall as “multipart” which means they contain several different parts, each containing a different type of data. MIME defines several header fields to help with the task of classifying and separating the “parts” of an email message. 

    Particularly, the Python libraries for email wrap much of the details surrounding the creation of MIME messages. This includes things like how to encode specific types of data so other email clients know how to decode the data, and creating message part boundary descriptions, which are often annoying low level tasks that the typical Python programmer doesn’t want to deal with directly.



     
     
    >>> More Python Articles          >>> More By Michael Swanson
     

       

    PYTHON ARTICLES

    - Tuples and Other Python Object Types
    - The Dictionary Python Object Type
    - String and List Python Object Types
    - Introducing Python Object Types
    - Mobile Programming using PyS60: Advanced UI ...
    - Nested Functions in Python
    - Python Parameters, Functions and Arguments
    - Python Statements and Functions
    - Statements and Iterators in Python
    - Sequences and Sets in Python
    - Python Expressions and Operators
    - Dictionaries, Variables and Statements in Py...
    - Data Types in Python
    - The Python Language
    - SSH with Twisted





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek