[Twisted-Python] (newbie!) smtp to message object
Fabio Sangiovanni
sangiovanni at nweb.it
Wed Nov 6 04:35:23 MST 2013
Il 06/11/13 12:09, Stacey Sern ha scritto:
> Hi,
>
> I also tried to figure out how to deliver one copy of a message
> instead of one for every recipient for a Twisted server tutorial
> (ticket #3324) which hasn't yet been finalized. Here's the way I went
> about it but I'd appreciate comments on the approach as well.
>
> For the IMessageDelivery.validateTo method, it generates the real
> IMessage object when it receives the first recipient. After that, it
> returns a NullMessage object for each subsequent recipient. The
> NullMessage object is called for each line received as part of the
> message but does nothing with it. Then you don't need to change
> _cbToValidate. Here's you're code with the modifications
> http://pastebin.com/6nFXiTgK.
>
> Stacey
Hi Stacey,
thanks for your reply.
I think your approach is cleaner than mine! Thanks!
My only concern is this loop in smtp.SMTP.do_DATA:
for (user, msgFunc) in recipients:
[...]
that implies a scan of the whole list of messages (made of the 'real'
message and of the other NullMessages).
I don't know how it can really impact on performances, though. I aimed
at not creating 'fake' messages at all, but it's not clear to me if it's
even possible without overriding _cbToValidate.
Let's keep in touch!
Fabio
>
>
>
> On Nov 6, 2013, at 5:08 AM, Fabio Sangiovanni <sangiovanni at nweb.it
> <mailto:sangiovanni at nweb.it>> wrote:
>
>> Hello list,
>>
>> I'm new to twisted and to python in general, so still deep in the
>> learning process.
>> Please forgive any faulty assumptions you'll find in this post :)
>>
>> I'm trying to accomplish to the following task: realize a tool that
>> acts as a proxy between the SMTP domain and the 'objects' domain.
>> That is: a daemon that listens for SMTP connections (relayed sessions
>> from Postfix) and bundles everything that belongs to a single session
>> (envelope sender, envelope recipients, headers, body) into an object
>> (it will probably become a JSON one day, not decided yet). The aim is
>> to allow further processing (es. publishing to a queue) of a
>> self-contained item.
>>
>> My (draft) implementation can be reached at http://pastebin.com/mbRztuid
>>
>> My main concerns are:
>> 1) am I using the right classes? My implementation leverages
>> twisted.mail.smtp, is this correct?
>> 2) I've overridden smtp.SMTP._cbToValidate; I really don't like this
>> very much (I'd like to leave the protocol untouched) but it's the
>> only way I've come up with (after several days of experiments :) ) to
>> have one single payload down the line (in smtp.SMTP.do_DATA), and not
>> one copy of the message for every single recipient. May this have bad
>> consequences?
>> 3) what do you think about the overall approach? could it have been
>> done differently/better?
>>
>> Thanks a lot for your help!
>>
>> Fabio
>> _______________________________________________
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
>> <mailto:Twisted-Python at twistedmatrix.com>
>> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20131106/67b6eef5/attachment-0001.html>
More information about the Twisted-Python
mailing list