Email

Three Major Components

  • message, ask questions about an existing email, to construct a new email, or to add or remove email subcomponents
  • parser, takes the serialized version of an email message (a stream of bytes) and converts it into a tree of EmailMessage objects
  • generator, takes an EmailMessage and turns it back into a serialized byte stream

Control Component

  • policy, EmailMessage, every generator, and every parser has an associated policy object that controls its behavior

Send Email

In [ ]:
# Import smtplib for the actual sending function
import smtplib

# Import the email modules we'll need
from email.mime.text import MIMEText

# Open a plain text file for reading.  For this example, assume that
# the text file contains only ASCII characters.
with open('e_1') as fp:
    # Create a text/plain message
    msg = MIMEText(fp.read())

# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'The contents of %s' % 'Email'
msg['From'] = 'lichen@valdosta.edu'
msg['To'] = 'lin.chen@ieee.org'

# Send the message via our own SMTP server.
s = smtplib.SMTP('127.0.0.1', 1025) # need SMTP server
s.send_message(msg)
s.quit()

Parse Email

In [58]:
import email.parser
import email

with open('e_1', 'rb') as fp:
    headers = email.parser.BytesParser(policy=email.policy.default).parse(fp) # EmailMessage
    print('To: '+headers['To'])
    print('From: '+headers['From'])
    print('Subject: '+headers['subject'])
    print('Content: '+headers.get_content().strip())
To: Chris Garrigues <cwg-dated-1030377287.06fa6d@DeepEddy.Com>
From: Robert Elz <kre@munnari.OZ.AU>
Subject: Re: New Sequences Window
Content: Date:        Wed, 21 Aug 2002 10:54:46 -0500
    From:        Chris Garrigues <cwg-dated-1030377287.06fa6d@DeepEddy.Com>
    Message-ID:  <1029945287.4797.TMDA@deepeddy.vircio.com>


  | I can't reproduce this error.

For me it is very repeatable... (like every time, without fail).

This is the debug log of the pick happening ...

18:19:03 Pick_It {exec pick +inbox -list -lbrace -lbrace -subject ftp -rbrace -rbrace} {4852-4852 -sequence mercury}
18:19:03 exec pick +inbox -list -lbrace -lbrace -subject ftp -rbrace -rbrace 4852-4852 -sequence mercury
18:19:04 Ftoc_PickMsgs {{1 hit}}
18:19:04 Marking 1 hits
18:19:04 tkerror: syntax error in expression "int ...

Note, if I run the pick command by hand ...

delta$ pick +inbox -list -lbrace -lbrace -subject ftp -rbrace -rbrace  4852-4852 -sequence mercury
1 hit

That's where the "1 hit" comes from (obviously).  The version of nmh I'm
using is ...

delta$ pick -version
pick -- nmh-1.0.4 [compiled on fuchsia.cs.mu.OZ.AU at Sun Mar 17 14:55:56 ICT 2002]

And the relevant part of my .mh_profile ...

delta$ mhparam pick
-seq sel -list


Since the pick command works, the sequence (actually, both of them, the
one that's explicit on the command line, from the search popup, and the
one that comes from .mh_profile) do get created.

kre

ps: this is still using the version of the code form a day ago, I haven't
been able to reach the cvs repository today (local routing issue I think).



_______________________________________________
Exmh-workers mailing list
Exmh-workers@redhat.com
https://listman.redhat.com/mailman/listinfo/exmh-workers