Python 2: SMTPServerDisconnected: соединение неожиданно закрытоPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Python 2: SMTPServerDisconnected: соединение неожиданно закрыто

Сообщение Anonymous »

У меня небольшая проблема с отправкой электронного письма на Python:

Код: Выделить всё

#me == my email address
#you == recipient's email address
me = "[email protected]"
you = "[email protected]"

# Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart('alternative')
msg['Subject'] = "Alert"
msg['From'] = me
msg['To'] = you

# Create the body of the message (a plain-text and an HTML version).
html = '
Hi, I have the following alerts for you!
'

# Record the MIME types of both parts - text/plain and text/html.
part2 = MIMEText(html, 'html')

# Attach parts into message container.
# According to RFC 2046, the last part of a multipart message, in this case
# the HTML message, is best and preferred.
msg.attach(part2)

# Send the message via local SMTP server.
s = smtplib.SMTP('aspmx.l.google.com')
# sendmail function takes 3 arguments: sender's address, recipient's address
# and message to send - here it is sent as one string.
s.sendmail(me, you, msg.as_string())
s.quit()
Итак, до сих пор моя программа не выдавала мне ошибок, но и не отправляла мне электронные письма. И теперь Python выдает мне ошибку:

Код: Выделить всё

SMTPServerDisconnected: Connection unexpectedly closed
Как это исправить?

Подробнее здесь: https://stackoverflow.com/questions/177 ... dly-closed
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»