import smtplib srv=smtplib.SMTP(server, port) srv.login(user_name, user_passwd)
Traceback (most recent call last):
File "D:\keys\run.py", line 49, in <module>
connect.sendmail (fromAddr, toAddr1, message)
File "D:\Program files\Python25\lib\smtplib.py", line 698, in sendmail
self.rset()
File "D:\Program files\Python25\lib\smtplib.py", line 453, in rset
return self.docmd("rset")
File "D:\Program files\Python25\lib\smtplib.py", line 378, in docmd
return self.getreply()
File "D:\Program files\Python25\lib\smtplib.py", line 355, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed")
SMTPServerDisconnected: Connection unexpectedly closed
fromAddr = mail1@mail.ru
toAddr = mail2@mail.ru
message = """From: Mailer <%(fromAddr)s>
To: <%(toAddr)s>
Subject: My Subject
MIME-Version: 1.0
Content-Type: text/plain; charset=Windows-1251
Content-Transfer-Encoding: 8bit
Тра-ля-ля.
"""
connect = SMTP ('smtp.mail.ru')
connect.login ("user", "password")
connect.sendmail (fromAddr, toAddr, message)
connect.quit
msg = MIMEText(message, "", "windows-1251")
# -*- coding: cp1251 -*-
import smtplib
# параметры SMTP-сервера
server = "194.67.23.114" # "smtp.bk.ru"
port = 25
user_name = "usrname"
user_passwd = "passwd"
s = smtplib.SMTP(server, port)
s.login(user_name, user_passwd)
s.connect()
s.connect()
File “C:\PROGRA~1\Python25\lib\smtplib.py”, line 310, in connect
raise socket.error, msg
socket.error: (10061, ‘Connection refused’)