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

Richard van de Stadt stadt at
Tue Oct 23 18:51:12 CEST 2001

Steve Holden wrote:

>     try:
>         mail = smtplib.SMTP(LocalMailServer)
>     except:
>         mail = smtplib.SMTP(altLocalMailServer)
>     mail.sendmail(fromaddr, recipients, message % locals())

> 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.

That hint helped.

Turns out the machine I was running this on doesn't have an smtp server.
Therefore smtplib.SMTP('localhost') didn't work out and raised an
exception, after which the altLocalMailServer was tried, which didn't
accept the request from this system (which is correct behavior :-)

Thanks a lot.


More information about the Python-list mailing list