problems with smtplib

Jon Hewer jonhewer at gmail.com
Fri Sep 2 05:59:13 EDT 2005


hi

having a few problems sending an email with smtplib.  i do have an
smtp server running on port 25 of my local machine

here's the relevant code (taken from python docs):

s = smtplib.SMTP('localhost')
s.connect()
s.sendmail(me, to, msg.as_string())
s.close()

and i'm getting this error:

Traceback (most recent call last):
  File "pysendmail.py", line 31, in ?
    s = smtplib.SMTP()
  File "/usr/lib/python2.3/smtplib.py", line 254, in __init__
    addr = socket.gethostbyname(socket.gethostname())
socket.gaierror: (-2, 'Name or service not known')

if i don't sepcify 'localhost' i get the same error

if i specify the port and local_hostname too

class SMTP([host[, port[, local_hostname]]])

then my script just freezing at some point trying to connect/send and
the email doesn't get sent

if anyone can help that would be great...

jon



More information about the Python-list mailing list