Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我首先尝试在我的 python 代码中使用 django send_mail 函数。
但是我的实时服务器不支持 SMTP,因此我被要求尝试使用 qmail-inject 或邮件,它们是 unix 命令。
有没有人这样做过?我们如何从 python 代码中设置主题、收件人等,并使用 qmail-inject 或作为 unix 命令的邮件发送电子邮件?
您需要创建一个自定义电子邮件后端来为您发送邮件。您可以自定义此代码段,它使用sendmail适合您场景的命令并将其替换为适当的命令。
sendmail
一旦你有你的自定义后端,设置EMAIL_BACKEND指向settings.pyPython模块路径 而不是文件系统路径。
EMAIL_BACKEND
settings.py