使用 django-registration 发送激活电子邮件
我很好奇是否有办法使用 django-registration 发送带有用户名和密码的激活电子邮件。首先我考虑修改注册表,但我需要一些例子。
I am curious if there's a way to send activated email with username, password by using django-registration. First I thought about modifying registration form but I need some example.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
django-registration 在内部使用以下代码来处理发送电子邮件:
如果您想工作,您必须在 settings.py 中指定值 DEFAULT_FROM_EMAIL。
另请注意以下事项:
因此,举个例子,这是我在 settings.py 文件中使用的 gmail 帐户:
django-registration 应该能够发送电子邮件。
django-registration uses the following code, internally, to handle sending emails:
If you want to work, you will have to specify the value DEFAULT_FROM_EMAIL in your settings.py.
Also, note the following:
So, to give an example, here's what I've used in a settings.py file to use a gmail account:
django-registration should then be able to send emails.
EMAIL_PORT = 465 一年前可用。现在您需要将端口 587 用于 gmail。
原因:Django从一开始就不支持带有SSL的SMTP。建立纯文本连接后仅支持 STARTTLS 命令。但是,Gmail 在端口 465 上不再支持此选项。
EMAIL_PORT = 465 was working some year ago. Now you need to use port 587 with gmail.
Reason: Django does not support SMTP with SSL from the beginning. Only STARTTLS command is supported AFTER plain-text connection is set up. Gmail, however, no longer supports this option on port 465.
希望这会对某人有所帮助。 时也必须明确声明这一点
经过半个小时的故障排除后,我意识到在使用 django-registration - EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
Hope this will help someone. After troubleshooting for half an hour, I realised that I had to explicitly state this as well while using django-registration -
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
django-register-activate 实现了与 django-registration 类似的功能。基本上它提供了用户注册、电子邮件验证和激活、用户登录和用户注销的代码。
如果您需要示例来实现自己的代码,您可以检查 register_activate 以获得一些提示。
希望答案有帮助。如果您还有其他问题,请告诉我。
django-register-activate implemented a similar functionality as django-registration. Basically it provides code for user sign up, email verification and activation, user login and user logout.
If you need examples to implement your own code, you may check the views.py and forms.py in register_activate to get some hints.
Hope the answer helps. Let me know if you have further questions.