为什么编译时我得到的用户名和密码不被接受?

Why when I compile I get username and password are not accepted?

这是我要编译的代码

from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
import smtplib
def send_mail(email, password, text):
        server = smtplib.SMTP_SSL("smtp.gmail.com:465")
        server.login(email, password)
        server.sendmail(email, email, text)
        text = msg.as_string() 
        server.quit()
        
f = open("c1.png")
send_mail("xxxxxxxxxxxxxx@gmail.com","xxxxxxxx",f)

和输出

这是我到目前为止尝试过的方法:

尝试从 apps password 生成密码并使用该代码代替用户的实际密码。

An App Password is a 16-digit passcode that gives an app or device restricted access to your Google Account without having to divulge your personal password and complete access to your Google Account.

有关 Sign in with App Passwords

的更多信息

这通常是由于用户启用了 2fa。