[Tutor] How to connect to an email server?
Eduardo Vieira
eduardo.susan at gmail.com
Mon Mar 16 20:34:53 CET 2009
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 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')
What should I do? And how can I know I can use smtp or IMAP?
More information about the Tutor
mailing list