[XML-SIG] smtpLib and xml_instance?

Jason Michael Jurkowski jasj@miller.cs.uwm.edu
Wed, 2 Apr 2003 19:52:09 -0600 (CST)


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
>