4 回答
TA贡献1909条经验 获得超7个赞
在Settings.py文件中添加以下代码
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'password' #my gmail password
EMAIL_HOST_USER = 'email' #my gmail username
EMAIL_PORT = 587
TA贡献1804条经验 获得超8个赞
将其添加到settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'password' #my gmail password
EMAIL_HOST_USER = 'email' #my gmail username
DEFAULT_FROM_EMAIL 'email' #my gmail username
EMAIL_PORT = 587
来自@Murlodin
这是配置中DEFAULT_FROM_EMAIL的默认设置EMAIL_FROMGRAPHQL_AUTH
EMAIL_FROM = getattr(django_settings, "DEFAULT_FROM_EMAIL", "test@email.com")
所以你可以从配置中更改DEFAULT_FROM_EMAIL或EMAIL_FROMGRAPHQL_AUTH
GRAPHQL_AUTH = {
#...
"EMAIL_FROM": 'email' #my gmail username
}
TA贡献1776条经验 获得超12个赞
您必须使用 JavaScript 从 URL 获取令牌。
例如,
const token = window.location.pathname.split("/").pop();
然后使用您在问题中提到的突变将此令牌发送回后端。
TA贡献1847条经验 获得超7个赞
如果使用Gmail ,请将下面的Gmail电子邮件设置添加到“settings.py”:
# "settings.py"
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'example@gmail.com' # Change to your email address
EMAIL_HOST_PASSWORD = 'examplePassword' # Change to your email password
或者,如果使用Outlook ,请将下面的Outlook电子邮件设置添加到“settings.py”:
# "settings.py"
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.office365.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'example@outlook.com' # Change to your email address
DEFAULT_FROM_EMAIL = 'example@outlook.com' # Change to your email address
SERVER_EMAIL = 'example@outlook.com' # Change to your email address
EMAIL_HOST_PASSWORD = 'examplePassword' # Change to your email password
添加回答
举报