Tell me, it took on Python to send a message to Yandex mail.
I found the code, but the error crashes.
Read, it is written that the error can fly, since the password may not be in the utf-8 encoding.
I write in the code for Password, addr_from, addr_to it is: encode (encoding = ‘utf-8’) – zero emotions.
Tell me how then fix the error?
import smtplib # Import library to work with SMTP
# Add the necessary subclasses - Mime-types
from email.mime.multipart import mimemultipart # multicomponent object
from email.mime.text Import MimeText # text / HTML
ADDR_FROM = "[email protected]"
ADDR_TO = "[email protected]"
Password = "Pass" # password from the mail addr_from
MSG = Mimemultipart () # Create a message
msg ['from'] = addr_from # addressee
msg ['to'] = addr_to # recipient
MSG ['SUBJECT'] = 'Message topic' # Message topic
Body = "Message Text"
MSG.attach (Body, 'Plain')) # add text to message
Server = smtplib.smtp_ssl ('smtp.yandex.ru', 465) # Create an SMTP object
# server.starttls () # start encrypted TLS exchange
Server.login (Addr_From, Password) # Get Access
Server.send_Message (MSG) # send a message
server.quit () # come out
Error:
smtplib.smtpauthenticationerror: (535, b'5.7.8 Error: Authentication Failed: This User Does Not Have Access Rights to this service ')
Answer 1, Authority 100%
just had an identical error with postcase on Yandex for local Hitlab. Based on the googling, usually associated with the use of features disconnected in the Yandex account settings.
In my case, it was helped to enable the “Portal Password” option.
Path to option:
- Click on the gear icon in the upper right corner
- in the drop-down menu: “Other”
- on the new page in the list on the left Select “Postal Programs”
- Put a checkbox on a checkbox “Portal Password”
Answer 2, Authority 100%
was the same problem, here the answer – https://searchengines.guru/ru/forum/1037543 .
Configure the box you need:
tried everyone, the decision was not obvious – helped
Prostanovka check box in the settings of the box from which is carried out
Departure: Mail- & gt; All settings – & gt; Postal programsAllow access to the mailbox using postal clients, section
IMAP, I put all the daws there, including in the POP3 sectionsection