Django + Graphene,注册用户后,一封确认信已到达开发者控制台。

我正在学习 Django + Graphene + React(Apollo),注册用户后,开发者控制台收到一封确认电子邮件。我怎样才能控制这封电子邮件?


class AuthMutation(graphene.ObjectType):

    register = mutations.Register.Field()

    verify_account = mutations.VerifyAccount.Field()

从客户端发送数据后,用户已注册,但为了确认它,我必须使用信件中的令牌执行突变。


mutation {

  verifyAccount(token: "YOUR TOKEN FROM LETTER") {

    success,

    errors

  }

}


<h3>{{ site_name }}</h3>


<p>Hello {{ user.username }}!</p>

<p>Please activate your account on the link:</p>


<p>{{ protocol }}://{{ domain }}/{{ path }}/{{ token }}</p>

我的目标是通过电子邮件确认注册


慕尼黑8549860
浏览 311回答 4
4回答

jeck猫

在Settings.py文件中添加以下代码EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'EMAIL_HOST = 'smtp.gmail.com'EMAIL_HOST_PASSWORD = 'password' #my gmail passwordEMAIL_HOST_USER = 'email' #my gmail usernameEMAIL_PORT = 587

胡说叔叔

将其添加到settings.py:EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'EMAIL_HOST = 'smtp.gmail.com'EMAIL_HOST_PASSWORD = 'password' #my gmail passwordEMAIL_HOST_USER = 'email' #my gmail usernameDEFAULT_FROM_EMAIL 'email' #my gmail usernameEMAIL_PORT = 587来自@Murlodin这是配置中DEFAULT_FROM_EMAIL的默认设置EMAIL_FROMGRAPHQL_AUTHEMAIL_FROM = getattr(django_settings, "DEFAULT_FROM_EMAIL", "test@email.com")所以你可以从配置中更改DEFAULT_FROM_EMAIL或EMAIL_FROMGRAPHQL_AUTHGRAPHQL_AUTH = {&nbsp; &nbsp; #...&nbsp; &nbsp; "EMAIL_FROM": 'email' #my gmail username}

叮当猫咪

您必须使用 JavaScript 从 URL 获取令牌。例如,const&nbsp;token&nbsp;=&nbsp;window.location.pathname.split("/").pop();然后使用您在问题中提到的突变将此令牌发送回后端。

aluckdog

如果使用Gmail ,请将下面的Gmail电子邮件设置添加到“settings.py”:# "settings.py"EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'EMAIL_HOST = 'smtp.gmail.com'EMAIL_PORT = 587EMAIL_USE_TLS = TrueEMAIL_HOST_USER = 'example@gmail.com' # Change to your email addressEMAIL_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 = 587EMAIL_USE_TLS = TrueEMAIL_HOST_USER = 'example@outlook.com' # Change to your email addressDEFAULT_FROM_EMAIL = 'example@outlook.com' # Change to your email addressSERVER_EMAIL = 'example@outlook.com' # Change to your email addressEMAIL_HOST_PASSWORD = 'examplePassword' # Change to your email password
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python