我正在尝试给自己发送一封电子邮件。所有 2 封电子邮件都是我的。我使用操作系统、电子邮件、smtplib 以及远程机器人。
代码:
@bot.message_handler(commands=['test'])
def test_message(messagep):
message = "WORKED!"
bot.send_message(messagep.chat.id, test(message=message))
def test(message):
sender = "[email protected]"
orders = "[email protected]"
password = os.getenv("app_password_email")
print(message)
server = smtplib.SMTP("smtp.yandex.ru", 587)
server.starttls()
try:
server.login(sender, password)
server.sendmail(sender, orders, message)
return "The message was sent successfully!"
except Exception as _ex:
return f"{_ex}\nCheck your login or password please!"
错误:
'NoneType' object has no attribute 'encode'