在通过Django Rest框架注册用户时,是否有发送验证邮件的方法?我在我的User
模型中有以下代码:
from django.core.mail import send_mail
from config import settings
def email_user(self, subject, message, from_email=settings.DEFAULT_FROM_EMAIL, **kwargs):
send_mail(subject, message, from_email, [self.email], fail_silently=False, **kwargs)
在我的settings.py
文件中:
EMAIL_USE_TLS = True
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = '`132312123'
EMAIL_HOST_USER = 'mimic@gmail.com'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
但是邮件没有发送,我希望有验证电子邮件服务,这样当用户单击链接时就可以激活。如何实现这些?