lnxnb
lnxnb

Reputation: 13

Djoser not sending verification email with Google Workspace

I'm making a Django Webapp following the tutorial here. I have gotten everything to work up to a certain point. When I send the POST request to my djoser endpoint with my user information, I get back the same response he did in the video with status 201 and the name email and id fields presented back. However, I do not get a confirmation email like he does. The salient difference is that I am not using a vanilla gmail account like the demonstrator is. I have a custom domain hosted through Google Domains for which I also have a Google Workspace account. I can access this account's gmail inbox through the gmail website, and I can send and receive emails fine. However, confirmation emails will not send.

I additionally followed the steps in this guide and they still would not send. Worth noting is that when I look at the google account's log in history, my app password has no record of being used. Any insight would be helpful. Here is the section of my settings.py that contains the relevant settings:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.Emailbackend'
EMAIL_HOST = 'smtp-relay.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = '**** **** **** ****' 
(I have tried the app password both in the original version with spaces google gave me, as well as without spaces.)
EMAIL_USE_TLS = True

Upvotes: 0

Views: 283

Answers (1)

carmel26
carmel26

Reputation: 1

I used Gmail in My code

*Before you must activate two way factory authentification on your gmail *
*After please copy the password and past it in password configuration *
Please can you try this code

EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'your gmail'
EMAIL_HOST_PASSWORD = 'add the password provided with your 2 factory authentification after anable it'
EMAIL_USE_TLS = True
DJOSER = {
    'LOGIN_FIELD' : 'email',
    'USER_CREATE_PASSWORD_RETYPE' : True,
    'USERNAME_CHANGED_EMAIL_CONFIRMATION' : True,
    'PASSWORD_CHANGED_EMAIL_CONFIRMATION' : True,
    'SEND_EMAIL_CONFIRMATION' : True,
    'SET_USERNAME_RETYPE' : True,
    'SET_PASSWORD_RETYPE' : True,
    'USERNAME_RESET_CONFIRM_URL' : 'password/reset/confirm/{uid}/{token}',
    'PASSWORD_RESET_CONFIRM_URL' : 'email/reset/confirm/{uid}/{token}',
    'ACTIVATION_URL' : 'activate/{uid}/{token}',
    'SEND_ACTIVATION_EMAIL' : True,
    'SERIALIZERS' : {
        'user_create' : 'api_APAP.serializers.UserCreateSerializer',
        'user' : 'api_APAP.serializers.UserCreateSerializer',
        'user_delete' : 'api_APAP.serializers.UserDeleteSerializer',
        'token': 'api_APAP.serializers.TokenSerializer',
        'user_registration': 'api_APAP.serializers.UserSerializer',
    },
}

Upvotes: 0

Related Questions