Django + Graphene, after registering a user, a confirmation letter has arrived in the developer's console. How can I get control of this email?
Question:
I am learning Django + Graphene + React(Apollo), after registering a user, a confirmation email has come to the developer console. How can I get control of this email?
class AuthMutation(graphene.ObjectType):
register = mutations.Register.Field()
verify_account = mutations.VerifyAccount.Field()
After I send data from the client side, the user is registered, but to confirm it, I have to perform a mutation with the token that comes in the letter.
mutation {
verifyAccount(token: "YOUR TOKEN FROM LETTER") {
success,
errors
}
}
Letter
<h3>{{ site_name }}</h3>
<p>Hello {{ user.username }}!</p>
<p>Please activate your account on the link:</p>
<p>{{ protocol }}://{{ domain }}/{{ path }}/{{ token }}</p>
My goal is to confirm registration via email
Answers:
You have to grab the token from the URL using JavaScript.
For example,
const token = window.location.pathname.split("/").pop();
And then send this token back to the backend using the mutation you mentioned in your question.
Added the following code to Settings.py file
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
Add this email settings for Gmail below to "settings.py" if using Gmail:
# "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 = '[email protected]' # Change to your email address
EMAIL_HOST_PASSWORD = 'examplePassword' # Change to your email password
Or, add this email settings for Outlook below to "settings.py" if using Outlook:
# "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 = '[email protected]' # Change to your email address
DEFAULT_FROM_EMAIL = '[email protected]' # Change to your email address
SERVER_EMAIL = '[email protected]' # Change to your email address
EMAIL_HOST_PASSWORD = 'examplePassword' # Change to your email password
Add This to 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
- from @Murlodin
The DEFAULT_FROM_EMAIL
is the default for EMAIL_FROM
in the GRAPHQL_AUTH
config as
EMAIL_FROM = getattr(django_settings, "DEFAULT_FROM_EMAIL", "[email protected]")
so you can either change the DEFAULT_FROM_EMAIL
or the EMAIL_FROM
from the GRAPHQL_AUTH
config like
GRAPHQL_AUTH = {
#...
"EMAIL_FROM": 'email' #my gmail username
}
I am learning Django + Graphene + React(Apollo), after registering a user, a confirmation email has come to the developer console. How can I get control of this email?
class AuthMutation(graphene.ObjectType):
register = mutations.Register.Field()
verify_account = mutations.VerifyAccount.Field()
After I send data from the client side, the user is registered, but to confirm it, I have to perform a mutation with the token that comes in the letter.
mutation {
verifyAccount(token: "YOUR TOKEN FROM LETTER") {
success,
errors
}
}
Letter
<h3>{{ site_name }}</h3>
<p>Hello {{ user.username }}!</p>
<p>Please activate your account on the link:</p>
<p>{{ protocol }}://{{ domain }}/{{ path }}/{{ token }}</p>
My goal is to confirm registration via email
You have to grab the token from the URL using JavaScript.
For example,
const token = window.location.pathname.split("/").pop();
And then send this token back to the backend using the mutation you mentioned in your question.
Added the following code to Settings.py file
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
Add this email settings for Gmail below to "settings.py" if using Gmail:
# "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 = '[email protected]' # Change to your email address
EMAIL_HOST_PASSWORD = 'examplePassword' # Change to your email password
Or, add this email settings for Outlook below to "settings.py" if using Outlook:
# "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 = '[email protected]' # Change to your email address
DEFAULT_FROM_EMAIL = '[email protected]' # Change to your email address
SERVER_EMAIL = '[email protected]' # Change to your email address
EMAIL_HOST_PASSWORD = 'examplePassword' # Change to your email password
Add This to 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
- from @Murlodin
The DEFAULT_FROM_EMAIL
is the default for EMAIL_FROM
in the GRAPHQL_AUTH
config as
EMAIL_FROM = getattr(django_settings, "DEFAULT_FROM_EMAIL", "[email protected]")
so you can either change the
DEFAULT_FROM_EMAIL
or theEMAIL_FROM
from theGRAPHQL_AUTH
config like
GRAPHQL_AUTH = {
#...
"EMAIL_FROM": 'email' #my gmail username
}