【发布时间】:2021-12-05 06:36:34
【问题描述】:
以下是我向我的用户发送邮件的代码:
mail = EmailMultiAlternatives(subject=subject, body=text_content, from_email="email@host.com", to=["email@host.com"], bcc=["email@host.com"])
mail.attach_file(model.document.path)
mail.attach_alternative(html_content, "text/html")
mail_status = mail.send()
我的settings.py如下:
EMAIL_HOST = "mail.host.com"
EMAIL_PORT = 587
EMAIL_HOST_USER = "email@host.com"
EMAIL_HOST_PASSWORD = str(os.getenv('EMAIL_HOST_PASSWORD'))
问题是上面的代码在我的本地 Windows 机器上运行得非常好,但是在运行 Ubuntu (Linux) 的远程服务器上运行时代码挂起并且没有显示输出。
知道我哪里出错了吗?
【问题讨论】:
标签: python django email smtplib django-email