smtplib.SMTPDataError: (503, 'Error: need RCPT command')

Steve Holden sholden at holdenweb.com
Tue Oct 23 00:58:03 EDT 2001


"Richard van de Stadt" <stadt at cs.utwente.nl> wrote in message
news:3BD4F3E8.1E4B826B at cs.utwente.nl...
> Hi,
>
> This is the first time I've been using the stuff below with Python 2.1.1
running
> on Solaris 5.8. I never got the error below before. It runs fine on Linux
with
> Python 1.5.2, and has been running fine for years on a Solaris 5.6 system,
with
> Python 1.5.2, 2.1 and 2.1.1. Could the error below be caused by Solaris
5.8's
> version of sendmail?
>
> Could anyone explain what this RCPT command is that seems to be needed?
>
> ---------------------
> mail.sendmail(fromaddr, recipients, message % locals())
>   File "/usr/local/pkg/Python-2.1.1/lib/python2.1/smtplib.py", line 496,
in sendmail
>     (code,resp) = self.data(msg)
>   File "/usr/local/pkg/Python-2.1.1/lib/python2.1/smtplib.py", line 386,
in data
>     raise SMTPDataError(code,repl)
> smtplib.SMTPDataError: (503, 'Error: need RCPT command')
> ---------------------
>
> Here's a part of my send_email function:
>     ...
>     fromstring = '...'
>     fromaddr = maintaineremail
>     cc_list = string.join ((chairemail, maintaineremail), ', ')
>     date = ctime(time())
>     dayName = date[:3] + ','
>     monthName = date[3:7]
>     day = date[7:10]
>     year = date[19:]
>     Time = date[10:19]
>     timeZone = ' ' + tzname[daylight]
>     date = dayName + day + monthName + year + Time + timeZone
>     message = """\
> Subject: %(subject)s
> Date: %(date)s
> From: %(fromstring)s <%(fromaddr)s>
> Reply-To: %(fromaddr)s
> To: %(to_list)s
> Cc: %(cc_list)s
> X-Mailer: Python smtplib
>
> %(body)s
> """
>     try:
>         mail = smtplib.SMTP(LocalMailServer)
>     except:
>         mail = smtplib.SMTP(altLocalMailServer)
>     mail.sendmail(fromaddr, recipients, message % locals())
>     mail.quit()
>
You appear to have overlooked setting a value for the "to_list" local
variable, and I don't see anything setting "recipients" either. It's
possible you simply omitted to include this section of your code, but an
empty recipient list might result in that error. smtplib line 386 raises an
error because the server doesn't give the expected reply when the client
starts to send the message body.

To check this, try adding

    mail.set_debuglevel(1)

before the .sendmail() call, which will give you a trace of client/server
interactions.

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list