`嗨,我正在使用 pythonanywhere 和我的 python 脚本。该脚本在我的电脑上运行正常,我收到一封电子邮件。但在 pythonanywhere 上它不起作用。
在我的示例中,我使用了错误的电子邮件和密码...
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import sys
#ivanjefrajer007
# Email configuration
sender_email = "[email protected]"
receiver_email = ["[email protected]"]
password = "xxx"
# Create a message object
message = MIMEMultipart()
message["From"] = sender_email
message["To"] = 'XXX'
message["Subject"] = "XXX"
html_body = """<html>
<body>
"""
# Email content
html_body = html_body + '''
<p>Google tabulky s rekordy zde </p>
</body>
</html>`your text`
'''
message.attach(MIMEText(html_body, "html"))
# Connect to the SMTP server
with smtplib.SMTP_SSL('smtp.seznam.cz', 465) as smtp:
print('Přihlašuji se...')
try:
smtp.login(sender_email, password)
except Exception as e:
print('Přihlášení se nepovedlo.', e)
sys.exit()
print('Odesílám email...')
try:
smtp.sendmail(sender_email, receiver_email, message.as_string())
smtp.quit()
except Exception as e:
print('Odeslání se nepovedlo.', e)
sys.exit()`
print('OK')
从 PythonAnywhere 定价页面我读到:
初学者:免费!
在 your-username.pythonanywhere.com 上拥有一个 Web 应用程序的有限帐户,从您的应用程序限制出站互联网访问,CPU/带宽低,不支持 IPython/Jupyter 笔记本。 它有效,并且是一个很好的入门方式!
如果您使用免费帐户,这是正常的。
他们在网站上提到所有付费计划都具有无限制的互联网访问,因此如果您想从程序访问互联网,我建议您尝试一下。