503 5.5.4 Bad sequence of commands. Yandex SMTP

делаю smtp клиент, авторизация проходит успешна, но дальнейшая команда MAIL FROM выдаёт ошибку 503 5.5.4 Bad sequence of commands. В чем вообще может быть проблема?

from socket import *
import base64

YOUR_EMAIL = "mymail"
YOUR_DESTINATION_EMAIL = "tomail"
YOUR_SUBJECT_EMAIL = "it's my subject"
YOUR_BODY_EMAIL = "email body for test"
my_pass = "pass"
msg = '{}. \r\nI love computer networks!'.format(YOUR_BODY_EMAIL)
endmsg = '\r\n.\r\n'
mailServer = 'smtp.yandex.ru'
mailPort = 25

clientSocket = socket(AF_INET, SOCK_STREAM)
clientSocket.connect((mailServer, mailPort))
recv = clientSocket.recv(1024)
print(recv)

heloCommand = 'HELO stackoverflow.com\r\n'
clientSocket.send(heloCommand.encode())
recv1 = clientSocket.recv(1024)
recv1 = recv1.decode()
print(recv1)

heloCommand = 'STARTTLS\r\n'
clientSocket.send(heloCommand.encode())
recv1 = clientSocket.recv(1024)
recv1 = recv1.decode()
print(recv1)

clientSocket = ssl.wrap_socket(clientSocket)

mailFromCommand = f"AUTH LOGIN\r\n"
clientSocket.send(mailFromCommand.encode())
recv2 = clientSocket.recv(1024).decode()
print(recv2)

mail_send = base64.b64encode(YOUR_EMAIL.encode())
clientSocket.send(mail_send + "\r\n".encode())
recv2 = clientSocket.recv(1024).decode()
print(recv2)

pass_send = base64.b64encode(my_pass.encode())
clientSocket.send(pass_send + "\r\n".encode())
recv2 = clientSocket.recv(1024).decode()
print(recv2)

mailfrom = f"MAIL FROM:<YOUR_EMAIL>\r\n"
clientSocket.send(mailfrom.encode())
recv2 = clientSocket.recv(1024).decode()
print(recv2)

rcptToCommand = f"RCPT TO:{YOUR_DESTINATION_EMAIL}\r\n"
clientSocket.send(rcptToCommand.encode())
recv3 = clientSocket.recv(1024).decode()
print(recv3)

datas = 'DATA\r\n'
clientSocket.send(datas.encode())
recv7 = clientSocket.recv(1024)
print(recv7)
clientSocket.send("Subject: {}\n\n{}".format(YOUR_SUBJECT_EMAIL, msg).encode())

clientSocket.send(endmsg.encode())
recv8 = clientSocket.recv(1024)
print(recv8)

quitcommand = 'QUIT\r\n'
clientSocket.send(quitcommand.encode())
recv9 = clientSocket.recv(1024)
print(recv9)

clientSocket.close()
print('Всё!')

b'220 vla3-aeadfdeff55e.qloud-c.yandex.net (Want to use Yandex.Mail for your domain? Visit http://pdd.yandex.ru) 1663672161-11111
250 vla3-aeadfdeff55e.qloud-c.yandex.net

D:\tg_projects\smtp_lab\app.py:32: DeprecationWarning: ssl.wrap_socket() is deprecated, use SSLContext.wrap_socket()
  clientSocket = ssl.wrap_socket(clientSocket)
220 Go ahead

334 VXNlcm5hbWU6

334 UGFzc3dvcmQ6

235 2.7.0 Authentication successful. 1663672162-51111

503 5.5.4 Bad sequence of commands. 1663672162-51111

b'221 2.0.0 Closing connecton\r\n'
Всё!

Process finished with exit code 0

Ответы (0 шт):