我有一个Django应用程序。在我的开发环境中,这个应用程序正在我的MacOSX10.9.3笔记本上运行。这个应用程序需要发送电子邮件。现在,我正在使用下面的python进程来模拟电子邮件服务器。
python -m smtpd -n -c DebuggingServer localhost:1025
此电子邮件服务器只需将电子邮件输出到stdout,然后将消息丢弃。
我希望这台服务器实际上发送电子邮件,而不是只是打印出来的标准输出。有人能告诉我怎么做吗?
发布于 2014-08-04 03:50:16
DebuggingServer
只是在stdout中显示消息:https://docs.python.org/2/library/smtpd.html#debuggingserver-objects
Create a new debugging server. Arguments are as per SMTPServer. Messages will be discarded, and printed on stdout.
如果您想直接向internet发送电子邮件,您必须通过配置好的MTA服务器发送邮件,您可以在Django内部的settings.py
中配置它:
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'youremail@gmail.com'
EMAIL_HOST_PASSWORD = 'yourpassword'
EMAIL_PORT = 587
您可以在https://docs.djangoproject.com/en/dev/ref/settings/#email-backend上阅读更多内容。
https://stackoverflow.com/questions/25111300
复制相似问题