PedroBern / django-graphql-auth

Django registration and authentication with GraphQL.

Home Page:https://django-graphql-auth.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I can't send an email to the user's email address with the account activation token

GoldGromofon91 opened this issue · comments

Prerequisites

  • Is it a bug?
  • Is it a new feature?
  • Is it a a question?
  • Can you reproduce the problem?
  • Are you running the latest version?
  • Did you check for similar issues?
  • Did you perform a cursory search?

For more information, see the CONTRIBUTING guide.

Description

I am trying to register a user using the register mutation, and send an email with the activation token to the user's email address.
I'm learning , and i'm understand what Django can send email using send_mail method but I don't know how to set up sending emails, there is nothing in the documentation, after registering the html from templates is sent directly to the django console of the project. And the problem is that I don't even know how she does it, since I did not write any code for this.
Before writing to you, I searched for similar questions on StackOverflow: but the proposed solutions did not lead to any result:
1.https://stackoverflow.com/questions/67382418/failed-to-send-email-using-gmail-as-client-django-graphene
2.https://stackoverflow.com/questions/64208685/django-graphene-after-registering-a-user-a-confirmation-letter-has-arrived-i
I apologize for my English, and hope you can help me

Steps to Reproduce

  1. [First Step]

      mutation {
       register(
         email: "useremail@gmail.com",
         username: "testemail",
         password1: "supersecretpass",
         password2: "supersecretpass",
       ) {
         success,
         errors
       }
     }
    

settings.py

    GRAPHENE = {
        "SCHEMA": "api.schema.schema",
        'MIDDLEWARE': [
            'graphql_jwt.middleware.JSONWebTokenMiddleware',
        ],
    }
    AUTHENTICATION_BACKENDS = [
        # 'graphql_jwt.backends.JSONWebTokenBackend',
        "graphql_auth.backends.GraphQLAuthBackend",
        'django.contrib.auth.backends.ModelBackend',
    ]
    GRAPHQL_JWT = {
        "JWT_VERIFY_EXPIRATION": True,
        "JWT_LONG_RUNNING_REFRESH_TOKEN": True,
        "JWT_ALLOW_ANY_CLASSES": [
            "graphql_auth.mutations.Register",
            "graphql_auth.mutations.VerifyAccount",
            "graphql_auth.mutations.VerifyToken",
            "graphql_auth.mutations.RefreshToken",
            "graphql_auth.mutations.ObtainJSONWebToken",
        ],
    }
    GRAPHQL_AUTH = {
        'LOGIN_ALLOWED_FIELDS': ['email', 'username'],
        'SEND_ACTIVATION_EMAIL': True,
    }

    AUTH_USER_MODEL = 'authuser.User'
    
    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    EMAIL_HOST = 'smtp.mail.ru'
    EMAIL_PORT = 2525
    EMAIL_HOST_USER = "corecthost@namehost.ru"
    EMAIL_HOST_PASSWORD = "user_host_password"
    EMAIL_USE_TLS = True

Expected behavior

Send an email with a token to the user's email address

Actual behavior

After performing the mutation, I get the following error:

    {
      "data": {
        "register": {
          "success": false,
          "errors": {
            "nonFieldErrors": [
              {
                "message": "Failed to send email.",
                "code": "email_fail"
              }
            ]
          },
          "token": null
        }
      }
    }

Requirements

    dj-database-url==0.5.0
    Django==2.2
    django-cors-headers==3.7.0
    django-filter==2.4.0
    django-graphql-auth==0.3.16
    django-graphql-jwt==0.3.0
    django-heroku==0.0.0
    graphene==2.1.8
    graphene-django==2.15.0
    graphql-core==2.3.2
    graphql-relay==2.0.1
    gunicorn==20.1.0
    mysqlclient==2.0.3
    Pillow==8.2.0
    promise==2.3
    psycopg2-binary==2.8.6
    PyJWT==1.7.1
    pytz==2021.1
    Rx==1.6.1
    singledispatch==3.6.1
    six==1.15.0
    sqlparse==0.4.1
    text-unidecode==1.3
    typing-extensions==3.7.4.3
    whitenoise==5.2.0

I found the error. You hide errors in your code, and output common errors like: "" so I didn't immediately find a solution, looking for a solution in your documentation found a solution by changing the basic 'EMAIL_FROM'setting:'noreply@itresume.ru'.

It would be great if the console still displayed errors during development

is this a problem?
django-heroku==0.0.0
should be 0.3.1
i have the same problem!

I have the same issue and it only happens in one of the heroku servers. It's so hard to debug this one

Hi , has anyone solve this ? When I first setup sending email verification with gmail was working fine , but now I've tried setting up with a professional email that has my domain name and is not working , then I've tried to change back to the gmail setup and is not working anymore.
I'm still getting :

{
  "data": {
    "register": {
      "success": false,
      "errors": {
        "nonFieldErrors": [
          {
            "message": "Failed to send email.",
            "code": "email_fail"
          }
        ]
      }
    }
  }
}