Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7287

Re: smtp - python

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <awilliam@whitemice.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'newbie': 0.03; 'wed,': 0.03; 'python': 0.08; 'postfix,': 0.09; 'question?': 0.09; 'wrote:': 0.14; 'subject:python': 0.14; '(get': 0.16; 'adam': 0.16; 'asyncore': 0.16; 'cyrus': 0.16; 'file).': 0.16; 'from:addr:awilliam': 0.16; 'from:addr:whitemice.org': 0.16; 'from:name:adam tauno williams': 0.16; 'message-id:@linux- yu4c.site': 0.16; 'received:72.14.190': 0.16; 'received:72.14.190.87': 0.16; 'received:mail.wmmi.net': 0.16; 'received:wmmi.net': 0.16; 'reply-to:addr:awilliam': 0.16; 'reply- to:addr:whitemice.org': 0.16; 'smtpd': 0.16; 'tmp': 0.16; 'header :In-Reply-To:1': 0.21; 'seems': 0.21; 'trying': 0.23; 'module,': 0.23; 'skip:b 20': 0.23; 'object': 0.26; 'received:72.14': 0.26; "i'm": 0.27; 'language.': 0.28; 'import': 0.29; 'server': 0.29; 'all,': 0.30; 'looks': 0.31; 'url:library': 0.31; 'someone': 0.33; 'to:addr:python-list': 0.33; 'file': 0.34; 'however,': 0.34; 'here,': 0.35; 'format.': 0.36; 'something': 0.37; 'url:docs': 0.37; 'another': 0.37; 'put': 0.37; 'url:python': 0.38; 'url:org': 0.38; 'subject:: ': 0.38; 'skip:s 20': 0.39; 'header:Mime- Version:1': 0.39; 'to:addr:python.org': 0.39; 'best': 0.60; 'enough,': 0.65; 'mailbox': 0.65; 'williams': 0.66; 'texts': 0.67; 'mails': 0.71; 'header:Reply-To:1': 0.72; 'reply-to:no real name:2**0': 0.72; 'stream': 0.77; '-0300,': 0.84; '17:18': 0.84; '?..': 0.84; 'adopt': 0.84; 'messages:': 0.84; 'novell': 0.84; 'transferred': 0.96
Subject Re: smtp - python
From Adam Tauno Williams <awilliam@whitemice.org>
To python-list@python.org
In-Reply-To <66527898-E2FA-4F23-A697-8E0A52911095@bsd.com.br>
References <66527898-E2FA-4F23-A697-8E0A52911095@bsd.com.br>
Content-Type text/plain; charset="UTF-8"
Date Thu, 09 Jun 2011 07:24:08 -0400
Mime-Version 1.0
X-Mailer Evolution 2.32.1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To awilliam@whitemice.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.50.1307618780.11593.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 82.94.164.166
X-Trace 1307618781 news.xs4all.nl 49177 [::ffff:82.94.164.166]:34454
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7287

Show key headers only | View raw


On Wed, 2011-06-08 at 17:18 -0300, Josias L.G wrote:
> Hi for all,
> I'm very newbie in python and is very good language.
> I'm trying to adopt a example:
> import smtpd
> import asyncore
> server = smtpd.PureProxy(('127.0.0.1', 1025), ('mail', 25))
> asyncore.loop()
> I'm trying to copy the email that is send to another email in maildir format.  
> Here, i'm reading about the mailbox module, however, i don't know how 
>start that (get the email that was transferred and, trought mailbox
>module, save all mails in one file). 
> an someone indicate something to me read ?.. examples... texts and 

I don't know much about the "mailbox" module; the documentation looks
straight-forward enough, what exactly is the question?
<http://docs.python.org/library/mailbox.html>?

If you want to put all the messages in a single file use mbox.

import mailbox
mybox = mailbox.mbox('my.mbox', create=True)
mybox.lock()
for message in messages:
    mybox.add(message)
mybox.flush()
mybox.unlock()
mybox.close()


To read a message into a Message object from a stream/file -

from email               import message_from_file
message = message_from_file(stream)

The best way to serialize a Message to a stream seems to be

from email.generator import Generator
tmp = BLOBManager.ScratchFile() # Create a stream
g = Generator(tmp, mangle_from_=False, maxheaderlen=60)
g.flatten(message)
tmp.seek(0)

-- 
Adam Tauno Williams <awilliam@whitemice.org> LPIC-1, Novell CLA
<http://www.whitemiceconsulting.com>
OpenGroupware, Cyrus IMAPd, Postfix, OpenLDAP, Samba

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: smtp - python Adam Tauno Williams <awilliam@whitemice.org> - 2011-06-09 07:24 -0400

csiph-web