Re: [Zope] question on simple_send in MailHost

2006-07-19 Thread Tino Wildenhain

Andreas Jung wrote:



--On 18. Juli 2006 21:55:36 -1000 John Schinnerer <[EMAIL PROTECTED]> 
wrote:



Aloha,

I did try send() - it seems one must know something about RFC822 message
formatting to use it...?
I know nothing about that, and could not quickly find any clear and
concise howtos or tutorials, just verbose and confusing specs and mailing
list posts and so on.


Nonsense. The Python 'email' module is perfectly suited and documented 
(with examples). We use the 'email' module in various places for 
generating rfc822 compliant emails that are send through MailHost.send().


So you are writing a Product to enable it to python scripting? .-))

Well, its so easy... some of the beginners should be able to do it.

from AccessControl import allow_module, allow_class, allow_type

from formatter import BlockFormatter
from email.MIMEText import MIMEText
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.Header import Header
from MailCrypt import signmail
from email.Encoders import encode_base64

allow_class(BlockFormatter)
allow_class(MIMEBase)
allow_class(MIMEText)
allow_class(MIMEMultipart)
allow_class(Header)
allow_class(signmail)
allow_class(encode_base64)


would roughly do it.
Pack it nicely, add some ZMI howtos
and be ready :-)

Regards
Tino Wildenhain
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] question on simple_send in MailHost

2006-07-19 Thread Andreas Jung



--On 18. Juli 2006 21:55:36 -1000 John Schinnerer <[EMAIL PROTECTED]> 
wrote:



Aloha,

I did try send() - it seems one must know something about RFC822 message
formatting to use it...?
I know nothing about that, and could not quickly find any clear and
concise howtos or tutorials, just verbose and confusing specs and mailing
list posts and so on.


Nonsense. The Python 'email' module is perfectly suited and documented 
(with examples). We use the 'email' module in various places for generating 
rfc822 compliant emails that are send through MailHost.send().


-aj

pgpTYhJi1eQ5c.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] question on simple_send in MailHost

2006-07-19 Thread John Schinnerer

Aloha,

I did try send() - it seems one must know something about RFC822 message 
formatting to use it...?
I know nothing about that, and could not quickly find any clear and 
concise howtos or tutorials, just verbose and confusing specs and 
mailing list posts and so on.


I tried using send() with the same plain text body and from and to 
strings I was using for simple_send()...in case it might work...
When the mail arrived, some of the header content was in the body and 
not in the header.

It did arrive at all addresses in the To: field, I will admit... :-)
But the header was broken somehow, I assume because I didn't know how to 
format it correctly.

That was all the time I had to mess with it for now.

thanks,
John S.

Andreas Jung wrote:



--On 18. Juli 2006 21:23:59 -1000 John Schinnerer <[EMAIL PROTECTED]> 
wrote:



Aloha,

Thanks all for the suggestions...for the time being I can do what I need
by sending to only one address.
It was trying to test the send by sending to multiple addresses (mine and
others') that brought this out...
I will try a list next time I need multiple addresses in the To: field.



Why don't you use the send() method which works perfectly fine with 
multiple

recipient addresses???

-aj





___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce

 http://mail.zope.org/mailman/listinfo/zope-dev )


--

John Schinnerer - MA, Whole Systems Design
--
- Eco-Living -
Whole Systems Design Services
People - Place - Learning - Integration
[EMAIL PROTECTED]
http://eco-living.net
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] question on simple_send in MailHost

2006-07-19 Thread Andreas Jung



--On 18. Juli 2006 21:23:59 -1000 John Schinnerer <[EMAIL PROTECTED]> 
wrote:



Aloha,

Thanks all for the suggestions...for the time being I can do what I need
by sending to only one address.
It was trying to test the send by sending to multiple addresses (mine and
others') that brought this out...
I will try a list next time I need multiple addresses in the To: field.


Why don't you use the send() method which works perfectly fine with multiple
recipient addresses???

-aj



pgpd01yeD4Zfo.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] question on simple_send in MailHost

2006-07-19 Thread John Schinnerer

Aloha,

Thanks all for the suggestions...for the time being I can do what I need 
by sending to only one address.
It was trying to test the send by sending to multiple addresses (mine 
and others') that brought this out...

I will try a list next time I need multiple addresses in the To: field.

thanks,
John S.

Jonathan wrote:


- Original Message - From: "John Schinnerer" <[EMAIL PROTECTED]>
To: 
Sent: Sunday, July 16, 2006 11:49 PM
Subject: [Zope] question on simple_send in MailHost



Aloha,

The Zope (2.7.5) API docs for MailHost show this for simple_send:

--
simple_send(self, mto, mfrom, subject, body):

Sends a message. Only To:, From: and Subject: headers can be set. 
The arguments are:


mto
A commaseparated string or list of recipient(s) of the message.
mfrom
The address of the message sender.
subject
The subject of the message.
body
The body of the message.
--

So it reads like it can handle more than one To: address, something 
like this comma-separated string:


'[EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED]'

...but when I do this the message only gets sent to the first address 
in the list.




I have never used simple_send..., but have you tried putting the 'To' 
addresses in a list format, eg. ['addr1', 'addr2', ...]?  - if you 
already have a comma-separated string you can easily pass this as a list 
with something like:  string.split(addressString, ',').



Jonathan

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )



--

John Schinnerer - MA, Whole Systems Design
--
- Eco-Living -
Whole Systems Design Services
People - Place - Learning - Integration
[EMAIL PROTECTED]
http://eco-living.net
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] question on simple_send in MailHost

2006-07-17 Thread Jonathan


- Original Message - 
From: "John Schinnerer" <[EMAIL PROTECTED]>

To: 
Sent: Sunday, July 16, 2006 11:49 PM
Subject: [Zope] question on simple_send in MailHost



Aloha,

The Zope (2.7.5) API docs for MailHost show this for simple_send:

--
simple_send(self, mto, mfrom, subject, body):

Sends a message. Only To:, From: and Subject: headers can be set. The 
arguments are:


mto
A commaseparated string or list of recipient(s) of the message.
mfrom
The address of the message sender.
subject
The subject of the message.
body
The body of the message.
--

So it reads like it can handle more than one To: address, something like 
this comma-separated string:


'[EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED]'

...but when I do this the message only gets sent to the first address in 
the list.




I have never used simple_send..., but have you tried putting the 'To' 
addresses in a list format, eg. ['addr1', 'addr2', ...]?  - if you already 
have a comma-separated string you can easily pass this as a list with 
something like:  string.split(addressString, ',').



Jonathan

___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] question on simple_send in MailHost

2006-07-17 Thread knitti

On 7/17/06, Andreas Jung <[EMAIL PROTECTED]> wrote:

Put this in the bugtracker...otherwise it will be lost.


will do on one of the next days...

--knitti
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] question on simple_send in MailHost

2006-07-17 Thread Andreas Jung

Put this in the bugtracker...otherwise it will be lost.

-aj

--On 17. Juli 2006 11:29:07 +0200 knitti <[EMAIL PROTECTED]> wrote:


On 7/17/06, John Schinnerer <[EMAIL PROTECTED]> wrote:

The Zope (2.7.5) API docs for MailHost show this for simple_send:

--
simple_send(self, mto, mfrom, subject, body):

 Sends a message. Only To:, From: and Subject: headers can be set.
The arguments are:

 mto
 A commaseparated string or list of recipient(s) of the message.
 mfrom
 The address of the message sender.
 subject
 The subject of the message.
 body
 The body of the message.
--


a bit digging in the code on one of my installations (2.7.4) revealed,
that Zope more or less directly invokes  SMTP.sendmail from smtplib
of python. quote from the docs: "a list of RFC 822 to-address strings
(a bare string will be treated as a list with 1 address)"

this seems a small bug in zope (either implementation or
documentation). for a fix, make the list yourself:

yourstring.split(',')

this _could_ break the RFC-conformity of the to-header of the message,
because simple_send builds the body of the message like this:

body="From: %s\nTo: %s\nSubject: %s\n\n%s" \
% (mfrom, mto, subject, body)

which would result in

To: ['[EMAIL PROTECTED]','[EMAIL PROTECTED]','[EMAIL PROTECTED]']

which makes the message unroutable.

I suggest this code for MailBase.simple_send() (Malhost.py):

import types # this belongs into the import section

[.. snip, in simple_send: ..]

def simple_send(self, mto, mfrom, subject, body):
if type(mto)==types.ListType:
body = "From: %s\nTo: %s\nSubject: %s\n\n%s" \
% (mfrom, ','.join(mto), subject, body)
else:
body = "From: %s\nTo: %s\nSubject: %s\n\n%s" \
% (mfrom, mto, subject, body)
self._send(mfrom, mto, body)

and change the documentation to accept lists and strings,
because parsing a comma-separated list of true rfc-822
addresses is far more complicarted than somestring.split(',')

--knitti
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -  http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )




--
ZOPYX Ltd. & Co. KG - Charlottenstr. 37/1 - 72070 Tübingen - Germany
Web: www.zopyx.com - Email: [EMAIL PROTECTED] - Phone +49 - 7071 - 793376
E-Publishing, Python, Zope & Plone development, Consulting


pgpwU6xYWO0ti.pgp
Description: PGP signature
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] question on simple_send in MailHost

2006-07-17 Thread knitti

i'd like to mention that I didn't test that code

--knitti
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


Re: [Zope] question on simple_send in MailHost

2006-07-17 Thread knitti

On 7/17/06, John Schinnerer <[EMAIL PROTECTED]> wrote:

The Zope (2.7.5) API docs for MailHost show this for simple_send:

--
simple_send(self, mto, mfrom, subject, body):

 Sends a message. Only To:, From: and Subject: headers can be set.
The arguments are:

 mto
 A commaseparated string or list of recipient(s) of the message.
 mfrom
 The address of the message sender.
 subject
 The subject of the message.
 body
 The body of the message.
--


a bit digging in the code on one of my installations (2.7.4) revealed,
that Zope more or less directly invokes  SMTP.sendmail from smtplib
of python. quote from the docs: "a list of RFC 822 to-address strings
(a bare string will be treated as a list with 1 address)"

this seems a small bug in zope (either implementation or
documentation). for a fix, make the list yourself:

yourstring.split(',')

this _could_ break the RFC-conformity of the to-header of the message,
because simple_send builds the body of the message like this:

body="From: %s\nTo: %s\nSubject: %s\n\n%s" \
   % (mfrom, mto, subject, body)

which would result in

To: ['[EMAIL PROTECTED]','[EMAIL PROTECTED]','[EMAIL PROTECTED]']

which makes the message unroutable.

I suggest this code for MailBase.simple_send() (Malhost.py):

import types # this belongs into the import section

[.. snip, in simple_send: ..]

def simple_send(self, mto, mfrom, subject, body):
   if type(mto)==types.ListType:
   body = "From: %s\nTo: %s\nSubject: %s\n\n%s" \
   % (mfrom, ','.join(mto), subject, body)
   else:
   body = "From: %s\nTo: %s\nSubject: %s\n\n%s" \
   % (mfrom, mto, subject, body)
   self._send(mfrom, mto, body)

and change the documentation to accept lists and strings,
because parsing a comma-separated list of true rfc-822
addresses is far more complicarted than somestring.split(',')

--knitti
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )


[Zope] question on simple_send in MailHost

2006-07-16 Thread John Schinnerer

Aloha,

The Zope (2.7.5) API docs for MailHost show this for simple_send:

--
simple_send(self, mto, mfrom, subject, body):

Sends a message. Only To:, From: and Subject: headers can be set. 
The arguments are:


mto
A commaseparated string or list of recipient(s) of the message.
mfrom
The address of the message sender.
subject
The subject of the message.
body
The body of the message.
--

So it reads like it can handle more than one To: address, something like 
this comma-separated string:


'[EMAIL PROTECTED],[EMAIL PROTECTED],[EMAIL PROTECTED]'

...but when I do this the message only gets sent to the first address in 
the list.


Is this a mistake in the docs - do I need to use send() to send to 
multiple addresses?


Or is there something wrong with my comma-separated string of recipients?

Or is there a third possibility I haven't even considered... :-)

thanks,
John S.

--

John Schinnerer - MA, Whole Systems Design
--
- Eco-Living -
Whole Systems Design Services
People - Place - Learning - Integration
[EMAIL PROTECTED]
http://eco-living.net
___
Zope maillist  -  Zope@zope.org
http://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope-dev )