Eduardo Vieira wrote:
Hello, I'm fairly new to programming and Python and am trying to
explore Python's email libraries. But I am having trouble making a
connection with an email server, I guess.
I'm running Windows XP, in a server environment. I have administrator
privileges to my machine (not the server machine) to install, delete
programs, for example. My email program (Outlook 2007) says that
Exchange Server is albertapdc.express.local
I would like to send emails using smtp in a script, but when I do
these lines, I get an error:

import smtplib
server = smtplib.SMTP('localhost') # if I replace 'localhost' with
'albertapdc.express.local' I get the same.

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Python25\lib\smtplib.py", line 244, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Python25\lib\smtplib.py", line 310, in connect
    raise socket.error, msg
error: (10061, 'Connection refused')

The server refuses your connection attempt...


The same error 'Connection refused' I get trying IMAP:
import imaplib
se = imaplib.IMAP4('albertapdc.express.local')
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Python25\lib\imaplib.py", line 163, in __init__
    self.open(host, port)
  File "C:\Python25\lib\imaplib.py", line 230, in open
    self.sock.connect((host, port))
  File "<string>", line 1, in connect
error: (10061, 'Connection refused')

The server again refuses your connection attempt...


What should I do?

I'd start by pinging the server and running nmap on it. Forget imap if your goal is sending mail. If you don't see port 25 or 465 opened you won't make it much further without getting the mail system administrator's help.

HTH,

Emile


And how can I know I can use smtp or IMAP?
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor


_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to