Вот такой код :
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
addr_from = "reciver@mail.ru" #Эти данные я меняю на настоящие
addr_to = "sender@mail.ru"
password = "passwor"
msg = MIMEMultipart()
msg['From'] = addr_from
msg['To'] = addr_to
msg['Subject'] = 'Тема сообщения'
body = "Текст сообщения"
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('smtp.mail.ru',465)
server.set_debuglevel(True)
server.starttls()
server.login(addr_from, password)
server.send_message(msg)
server.quit()
использую Python 3.8 и 3.7
ошибки
Traceback (most recent call last):
server = smtplib.SMTP('smtp.mail.ru',465)
line 251, in __init__
(code, msg) = self.connect(host, port)
line 338, in connect
(code, msg) = self.getreply()
line 394, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
Двухэтапную аунтификацию выключил
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
addr_from = "reciver@mail.ru" #Эти данные я меняю на настоящие
addr_to = "sender@mail.ru"
password = "passwor"
msg = MIMEMultipart()
msg['From'] = addr_from
msg['To'] = addr_to
msg['Subject'] = 'Тема сообщения'
body = "Текст сообщения"
msg.attach(MIMEText(body, 'plain'))
server = smtplib.SMTP('smtp.mail.ru',465)
server.set_debuglevel(True)
server.starttls()
server.login(addr_from, password)
server.send_message(msg)
server.quit()
использую Python 3.8 и 3.7
ошибки
Traceback (most recent call last):
server = smtplib.SMTP('smtp.mail.ru',465)
line 251, in __init__
(code, msg) = self.connect(host, port)
line 338, in connect
(code, msg) = self.getreply()
line 394, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
Двухэтапную аунтификацию выключил