因此,基本上我正在尝试开发一个python程序,它允许我在不登录的情况下向我朋友的电子邮件发送电子邮件。但是,我收到一个错误,显示为smtplib.SMTPRecipientsRefused
这是我的代码..
import smtplib
myemail = 'myemail@gmail.com'
mypassword = 'password'
friendemail = input('Please enter the email of the person:')
with smtplib.SMTP("smtp.gmail.com", 587) as smtp:
subject = input("Subject: ")
body = input('Message:')
msg = f"subject:{subject}\n\n{body}"
smtp.starttls()
smtp.login(myemail,mypassword)
smtp.sendmail(myemail, mypassword, msg)如果有人能帮忙那就太好了!谢谢!
发布于 2020-07-17 14:18:24
我尝试运行您提供的代码,但下面的图像出现了问题,对吧?

根据提示,我更改了sendmail的参数。
smtp.sendmail(myemail, friendemail, msg)
这里的参数分别是:发件人邮箱、收件人邮箱、邮件内容。
更改后,我成功地在vscode中运行了它,并向我朋友的Gmail邮箱发送了一封电子邮件。
注意:邮箱名称和密码填写正确,不能遗漏。
https://stackoverflow.com/questions/62919035
复制相似问题