我输入了正确的电子邮件/密码,但它仍然无法登录该邮件/无法使用该邮件发送消息,因此它正在输出您输入的用户名或密码不正确任何人都可以帮忙请我找出问题并提出一个好的解决方案。
谢谢
-我
def Emailspam():
print("Choose your email provider")
print("1. Gmail")
print("2. Outlook")
provider = input(CRED + ">>> " + CEND)
os.system("cls")
useremail = input("EMAIL : ")
userpass = input("PASSWORD : ")
os.system("cls")
victimemail = input("Victim email : ")
Content = input('Message : ')
Number = int(input("Number of mail to send : "))
os.system("cls")
#https://www.androidauthority.com/gmail-smtp-settings-801100/#:~:text=SMTP%20server%20address%3A%20smtp.gmail,SMTP%20port%20(SSL)%3A%20465
if provider == ("1"):
smtp_server = 'smtp.gmail.com'
port = 587
#https://support.microsoft.com/en-us/office/pop-imap-and-smtp-settings-for-outlook-com-d088b986-291d-42b8-9564-9c414e2aa040
elif provider == ("2"):
smtp_server = 'smtp.office365.com'
port = 587
else:
print("Invalid choice")
skrr = input("press enter to close")
exit()
try:
server = smtplib.SMTP(smtp_server,port)
server.login(useremail,userpass)
for i in range(0,Number):
print("Number of Message Sent to " + victimemail + ":" , i+1)
server.starttls()
server.ehlo()
server.sendmail(useremail,victimemail,Content)
time.sleep(1)
server.close()
except Exception as e:
print('The username or password you entered is incorrect.')
p = input("Press enter to close")
exit()
答案 0 :(得分:0)
尝试创建应用密码,然后看看它是否有效。要创建应用密码,请转到您的帐户并进入隐私设置进行设置。另外,尝试添加:
server.ehlo()
之后:
server.starttls()
答案 1 :(得分:0)
Google 提高了安全性。因此,如果您没有从 Gmail 帐户关闭安全性较低的应用程序访问权限,您将无法登录任何 Gmail 帐户。要做到这一点,首先点击管理谷歌帐户 > 安全选项卡 > 不太安全的应用程序访问 > 关。这是一篇关于它的文章:How to turn off less secure app access in gmail
另一件事是您不应该将登录代码保留在 for 循环中。您应该在 for 循环之外登录。因此,您将登录一次并多次使用该帐户发送电子邮件。
希望能帮到你!
这是工作代码:
def Emailspam():
print("Choose your email provider")
print("1. Gmail")
print("2. Outlook")
provider = input(CRED + ">>> " + CEND)
os.system("cls")
useremail = input("EMAIL : ")
userpass = input("PASSWORD : ")
os.system("cls")
victimemail = input("Victim email : ")
Content = input('Message : ')
Number = int(input("Number of mail to send : "))
os.system("cls")
if provider == ("1"):
smtp_server = 'smtp.gmail.com'
port = 587
elif provider == ("2"):
smtp_server = 'smtp.office365.com'
port = 587
else:
print("Invalid choice")
skrr = input("press enter to close")
exit()
try:
server = smtplib.SMTP(smtp_server,port)
server.ehlo()
server.starttls()
server.login(useremail,userpass)
for i in range(0,Number):
print("Number of Message Sent to " + victimemail + ":" , i+1)
server.sendmail(useremail,victimemail,Content)
time.sleep(1)
server.close()
except Exception as e:
print('The username or password you entered is incorrect.')
p = input("Press enter to close")
exit()
答案 2 :(得分:0)
使用 server.connect 并在循环之外移动一些东西将修复它
def Emailspam():
print("Choose your email provider")
print("1. Gmail")
print("2. Outlook")
provider = input(CRED + ">>> " + CEND)
os.system("cls")
useremail = input("EMAIL : ")
userpass = input("PASSWORD : ")
os.system("cls")
victimemail = input("Victim email : ")
Content = input('Message : ')
Number = int(input("Number of mail to send : "))
os.system("cls")
#https://www.androidauthority.com/gmail-smtp-settings-801100/#:~:text=SMTP%20server%20address%3A%20smtp.gmail,SMTP%20port%20(SSL)%3A%20465
if provider == ("1"):
smtp_server = 'smtp.gmail.com'
port = 587
#https://support.microsoft.com/en-us/office/pop-imap-and-smtp-settings-for-outlook-com-d088b986-291d-42b8-9564-9c414e2aa040
elif provider == ("2"):
smtp_server = 'smtp.office365.com'
port = 587
else:
print("Invalid choice")
skrr = input("press enter to close")
exit()
try:
server = smtplib.SMTP(smtp_server,port)
server.connect(smtp_server,port)
server.ehlo()
server.starttls()
server.login(useremail,userpass)
for i in range(0,Number):
print("Number of Message Sent to " + victimemail + ":" , i+1)
server.sendmail(useremail,victimemail,Content)
time.sleep(1)
print("Finished")
server.close()
except Exception as e:
print(e)
print('The username or password you entered is incorrect.')
p = input("Press enter to close")
exit()