Avatar ·

django. 在 localhost 上发送 email

📁 python, 错误, 示例, 人工智能, 调试, 工作

请告诉我,我如何在本地服务器上向邮箱发送邮件。django 运行在 localhost:8080 上,为了发送邮件(如文档所述)需要 SMTP 服务器。我也启动了一个本地服务器。

python -m smtpd -n -c DebuggingServer localhost:1025

在 view 中得到 localhost:1025

send_mail('theme', 'my messege', 'admins@studio.ru',['a@a.ru'])

遇到了各种错误,例如 getaddrinfo(host, port),我在 view 中添加了

import socketsocket.getaddrinfo('localhost', 8080)

现在错误是 [Ero 11004] getaddrinfo failed

(code, msg) = self.connect(host, port)