[XML-SIG] smtpLib and xml_instance?

Terence Lo tlo@aw.sgi.com
Wed, 2 Apr 2003 17:52:34 -0500


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.