I'm trying to run the python code, but it gives an error. He writes that the username or password is incorrect, but everything is correct. In the mail I made it so that insecure applications could use
My code:
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
def send_email(to_addr,subject,text):
msg = MIMEMultipart()
msg["From"] = "[email protected]"
msg["To"] = "[email protected]"
msg["Subject"] = subject
msg.attach(MIMEText(text,"plain"))
server = smtplib.SMTP_SSL("smtp.yandex.ru",465)
server.ehlo("[email protected]")
server.login("[email protected]","password")
server.auth_plain()
server.send_message(msg)
server.quit()
if __name__=="__main__":
send_email("[email protected]","Theme","Hi")
Error: Traceback (most recent call last): File "C:\Users\fedos\PycharmProjects\botmanagerui\sender.py", line 22, in send_email("[email protected]","Theme","Hi") File "C:\Users\fedos\PycharmProjects\botmanagerui\sender.py", line 15, in send_email server.login("[email protected]","password") File "D:\Users\fedos\anaconda3\lib\smtplib.py", line 750, in login raise last_exception File "D:\Users\fedos\anaconda3\lib\smtplib.py", line 739, in login (code, resp) = self.auth( File "D:\Users\fedos\anaconda3\lib\smtplib.py", line 662, in auth raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, b'5.7.8 Error: authentication failed: Invalid user or password! 1682851755-FnItbCMDd8c0')
I tried to change the password, change the settings almost, but all to no avail