[XML-SIG] smtpLib and xml_instance?

Terence Lo tlo@aw.sgi.com
Thu, 3 Apr 2003 11:16:49 -0500


Thanks for the help Jason.

In case anyone runs into this problem, I've discovered a quick fix.

As it turns out, wrapping the PCDATA with an str() method and assigning it
to toaddrs seems to work quite nicely.

ie.: toaddrs = str(config.mailer.email.PCDATA)

Terence.

-----Original Message-----
From: Jason Michael Jurkowski [mailto:jasj@miller.cs.uwm.edu]
Sent: Wednesday, April 02, 2003 8:52 PM
To: Terence Lo
Cc: xml-sig@python.org
Subject: Re: [XML-SIG] smtpLib and xml_instance?


the print statement invokes the str() method of the object provided to it.
the str() method is providing the character data for that object.
i'm not familiar with the gnosis code but if CDATA is a 'CDATASection
Object' you want to assign PCDATA.data to toaddrs and pass that into the
smtplib code.

On Wed, 2 Apr 2003, Terence Lo wrote:

> Hi there,
> Just wondering if someone could help me out.  For some odd reason when I
run
> the following code snippet,
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> import sys, smtplib, string, os
> from gnosis.xml.objectify import XML_Objectify, pyobj_printer
>
> xml_obj = XML_Objectify('config.xml')
> config = xml_obj.make_instance()
>
> fromaddr = 'bob@asdf.com'
> toaddrs = config.mailer.email.PCDATA
>
> print toaddrs
>
> bodytext = 'this is the bodytext'
>
> smtp = smtplib.SMTP('mail.tor.aw.sgi.com')
> smtp.sendmail(fromaddr, toaddrs, bodytext)
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> OUTPUT:
>
>   File "C:\Python21\lib\smtplib.py", line 494, in sendmail
>     (code,resp) = self.data(msg)
>   File "C:\Python21\lib\smtplib.py", line 384, in data
>     raise SMTPDataError(code,repl)
> smtplib.SMTPDataError: (503, 'Need RCPT (recipient)')
>
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
>
> I get a  smtplib.SMTPDataError: (503, 'Need RCPT (recipient)') error.  Now
I
> know that I am fairly certain that the xml file that I am using is correct
> because when i print out the toaddrs variable, it correctly displays the
> correct email address.
>
> Now when I hardcode:
>
> toaddrs = "blah@blah.com"
>
> *instead of*
> toaddrs = config.mailer.email.PCDATA
>
> The smtplib.SMTPDataError doesn't occur.  If someone could this newbie
out,
> I would greatly appreciate it.
>
> Thanks in advance!
>
> Terence.
>
>
>
> _______________________________________________
> XML-SIG maillist  -  XML-SIG@python.org
> http://mail.python.org/mailman/listinfo/xml-sig
>