Home > Enterprise >  Sending email verfications works locally but doesnt work on heroku in my django app
Sending email verfications works locally but doesnt work on heroku in my django app

Time:07-27

i am using an email verfication using links once the user register an email is sent to the user to activate their account this works fine in my local app when i run it but after i deployed the app to heroku even tho i set the config vars to be the same as my enviroment vars i still get this error

(530, b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError t19-20020a05622a181300b0031e9b5ead3asm2297749qtc.76 - gsmtp', '[email protected]')

this error indicates that for some reason heroku cant access the gmail even tho i set an app password for it and this is my settings for heroku

DEFAULT_FROM_EMAIL = os.environ.get('EMAIL_FROM_USER')
EMAIL_FROM_USER = os.environ.get('EMAIL_FROM_USER')
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = os.environ.get('EMAIL_FROM_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
EMAIL_USE_SSL = True
EMAIL_PORT = 465
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/

STATIC_URL = '/static/'

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

CRISPY_TEMPLATE_PACK = 'bootstrap5'




# heruko settings
cwd = os.getcwd()

if cwd == '/app' or cwd[:4] =='/tmp':
    import dj_database_url
    DATABASES = {
        'default' : dj_database_url.config(default='postgres://localhost')
    }

    # honor the 'X-Forward-Proto' header for request.is_secure()
    SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARD_PROTO', 'https')
    DEBUG = False   
    #static asset configuration
    BASE_DIR = os.path.dirname(os.path.abspath(__file__))
    STATIC_ROOT = 'staticfiles'
    STATICFILES_DIR = (os.path.join(BASE_DIR, 'static'))

i am at my wits end tried many things and nothing worked out even chaning the email port number so any help will be appriciated

CodePudding user response:

This is the problem with gmail service, which doesn't allow cloud services to use it. Try other mail service.

  • Related