Define email service on GeoNode

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Define email service on GeoNode

Jose Cáceres
Hi,

I'm running Geonode on Docker.

I'm having troubles configuring the mail service for Geonode. I was able to have it up and running by defining the values directly on my settings.py file, like this:

EMAIL_ENABLE = ast.literal_eval(os.getenv('EMAIL_ENABLE', 'True'))

if EMAIL_ENABLE:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.smtp.EmailBackend')
    EMAIL_HOST = os.getenv('DJANGO_EMAIL_HOST', '
smtp.gmail.com')
    EMAIL_PORT = os.getenv('DJANGO_EMAIL_PORT', 587)
    EMAIL_HOST_USER = os.getenv('DJANGO_EMAIL_HOST_USER', '[hidden email]')
    EMAIL_HOST_PASSWORD = os.getenv('DJANGO_EMAIL_HOST_PASSWORD', 'mypassword')
    EMAIL_USE_TLS = ast.literal_eval(os.getenv('DJANGO_EMAIL_USE_TLS', 'True'))
    DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'GeoNode <[hidden email]>')
else:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.console.EmailBackend')


This way I was able to deliver messages to users, send notifications, etc.

But I don't want to have those values available on the settings.py, so I figure I could add the variales to my docker-compose file, like this:

DJANGO_EMAIL_HOST='smtp.gmail.com'
DJANGO_EMAIL_PORT=587
DJANGO_EMAIL_HOST_USER='[hidden email]'
DJANGO_EMAIL_HOST_PASSWORD='my password'


And I left the values on the settings.py by default:

EMAIL_ENABLE = ast.literal_eval(os.getenv('EMAIL_ENABLE', 'False'))

if EMAIL_ENABLE:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.smtp.EmailBackend')
    EMAIL_HOST = os.getenv('DJANGO_EMAIL_HOST', 'localhost')
    EMAIL_PORT = os.getenv('DJANGO_EMAIL_PORT', 25)
    EMAIL_HOST_USER = os.getenv('DJANGO_EMAIL_HOST_USER', '')
    EMAIL_HOST_PASSWORD = os.getenv('DJANGO_EMAIL_HOST_PASSWORD', '')
    EMAIL_USE_TLS = ast.literal_eval(os.getenv('DJANGO_EMAIL_USE_TLS', 'False'))
    DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'GeoNode <[hidden email]>')
else:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.console.EmailBackend')


But this way is not working, messages are not sent.

So I want to ask you what is the best way to configure the mail service.

Thanks in advanced.

José


--
José David Cáceres
Ingeniero Ambiental
Máster en Tecnologías de la Información Geográfica



Mailtrack Remitente notificado con
Mailtrack 21/05/20 15:36:45

_______________________________________________
geonode-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-users
Reply | Threaded
Open this post in threaded view
|

Re: Define email service on GeoNode

Jose Cáceres
Hi,

Sorry for wasting your time.

I created a new file, secret_codes.py, and I put my credentials in there:
MY_EMAIL_HOST='smtp.gmail.com'
MY_EMAIL_PORT=587
MY_EMAIL_HOST_USER='[hidden email]'
MY_EMAIL_HOST_PASSWORD='my password'
  

Then I import secret_codes into settings.py and change the variables like this:
    EMAIL_HOST = os.getenv('DJANGO_EMAIL_HOST', MY_EMAIL_HOST)  
    EMAIL_PORT = os.getenv('DJANGO_EMAIL_PORT', 
MY_EMAIL_PORT)
    EMAIL_HOST_USER = os.getenv('DJANGO_EMAIL_HOST_USER',
MY_EMAIL_HOST_USER)  
    EMAIL_HOST_PASSWORD = os.getenv('DJANGO_EMAIL_HOST_PASSWORD',
MY_EMAIL_HOST_PASSWORD) 

My main concern was to expose the information on my github repository, but this way I can add the secret_codes to the .gitignore file.

Everything seems to be working fine but I would still like to know if this is a good way to do it.

Kind regards,

José





Mailtrack Remitente notificado con
Mailtrack 21/05/20 17:18:13

On Thu, May 21, 2020 at 3:38 PM Jose Cáceres <[hidden email]> wrote:
Hi,

I'm running Geonode on Docker.

I'm having troubles configuring the mail service for Geonode. I was able to have it up and running by defining the values directly on my settings.py file, like this:

EMAIL_ENABLE = ast.literal_eval(os.getenv('EMAIL_ENABLE', 'True'))

if EMAIL_ENABLE:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.smtp.EmailBackend')
    EMAIL_HOST = os.getenv('DJANGO_EMAIL_HOST', '
smtp.gmail.com')
    EMAIL_PORT = os.getenv('DJANGO_EMAIL_PORT', 587)
    EMAIL_HOST_USER = os.getenv('DJANGO_EMAIL_HOST_USER', '[hidden email]')
    EMAIL_HOST_PASSWORD = os.getenv('DJANGO_EMAIL_HOST_PASSWORD', 'mypassword')
    EMAIL_USE_TLS = ast.literal_eval(os.getenv('DJANGO_EMAIL_USE_TLS', 'True'))
    DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'GeoNode <[hidden email]>')
else:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.console.EmailBackend')


This way I was able to deliver messages to users, send notifications, etc.

But I don't want to have those values available on the settings.py, so I figure I could add the variales to my docker-compose file, like this:

DJANGO_EMAIL_HOST='smtp.gmail.com'
DJANGO_EMAIL_PORT=587
DJANGO_EMAIL_HOST_USER='[hidden email]'
DJANGO_EMAIL_HOST_PASSWORD='my password'


And I left the values on the settings.py by default:

EMAIL_ENABLE = ast.literal_eval(os.getenv('EMAIL_ENABLE', 'False'))

if EMAIL_ENABLE:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.smtp.EmailBackend')
    EMAIL_HOST = os.getenv('DJANGO_EMAIL_HOST', 'localhost')
    EMAIL_PORT = os.getenv('DJANGO_EMAIL_PORT', 25)
    EMAIL_HOST_USER = os.getenv('DJANGO_EMAIL_HOST_USER', '')
    EMAIL_HOST_PASSWORD = os.getenv('DJANGO_EMAIL_HOST_PASSWORD', '')
    EMAIL_USE_TLS = ast.literal_eval(os.getenv('DJANGO_EMAIL_USE_TLS', 'False'))
    DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'GeoNode <[hidden email]>')
else:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.console.EmailBackend')


But this way is not working, messages are not sent.

So I want to ask you what is the best way to configure the mail service.

Thanks in advanced.

José


--
José David Cáceres
Ingeniero Ambiental
Máster en Tecnologías de la Información Geográfica



Mailtrack Remitente notificado con
Mailtrack 21/05/20 15:36:45


--
José David Cáceres
Ingeniero Ambiental
Máster en Tecnologías de la Información Geográfica

_______________________________________________
geonode-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-users
Reply | Threaded
Open this post in threaded view
|

Re: Define email service on GeoNode

Alessio Fabiani-2
In reply to this post by Jose Cáceres
Hi Jose,
in GeoNode the recommended way is to use environment variables always.
There is logic on original settings which depends on some env values. That means that it is not simply matter to override a variable sometimes.

In your case I guess the error is that the values of end on docker-compose and uwsgi do not require quotes nor double quotes except in very special cases when you have characters that conflicts with the shell.

-A.



Il giorno gio 21 mag 2020 alle ore 23:38 Jose Cáceres <[hidden email]> ha scritto:
Hi,

I'm running Geonode on Docker.

I'm having troubles configuring the mail service for Geonode. I was able to have it up and running by defining the values directly on my settings.py file, like this:

EMAIL_ENABLE = ast.literal_eval(os.getenv('EMAIL_ENABLE', 'True'))

if EMAIL_ENABLE:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.smtp.EmailBackend')
    EMAIL_HOST = os.getenv('DJANGO_EMAIL_HOST', '
smtp.gmail.com')
    EMAIL_PORT = os.getenv('DJANGO_EMAIL_PORT', 587)
    EMAIL_HOST_USER = os.getenv('DJANGO_EMAIL_HOST_USER', '[hidden email]')
    EMAIL_HOST_PASSWORD = os.getenv('DJANGO_EMAIL_HOST_PASSWORD', 'mypassword')
    EMAIL_USE_TLS = ast.literal_eval(os.getenv('DJANGO_EMAIL_USE_TLS', 'True'))
    DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'GeoNode <[hidden email]>')
else:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.console.EmailBackend')


This way I was able to deliver messages to users, send notifications, etc.

But I don't want to have those values available on the settings.py, so I figure I could add the variales to my docker-compose file, like this:

DJANGO_EMAIL_HOST='smtp.gmail.com'
DJANGO_EMAIL_PORT=587
DJANGO_EMAIL_HOST_USER='[hidden email]'
DJANGO_EMAIL_HOST_PASSWORD='my password'


And I left the values on the settings.py by default:

EMAIL_ENABLE = ast.literal_eval(os.getenv('EMAIL_ENABLE', 'False'))

if EMAIL_ENABLE:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.smtp.EmailBackend')
    EMAIL_HOST = os.getenv('DJANGO_EMAIL_HOST', 'localhost')
    EMAIL_PORT = os.getenv('DJANGO_EMAIL_PORT', 25)
    EMAIL_HOST_USER = os.getenv('DJANGO_EMAIL_HOST_USER', '')
    EMAIL_HOST_PASSWORD = os.getenv('DJANGO_EMAIL_HOST_PASSWORD', '')
    EMAIL_USE_TLS = ast.literal_eval(os.getenv('DJANGO_EMAIL_USE_TLS', 'False'))
    DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'GeoNode <[hidden email]>')
else:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.console.EmailBackend')


But this way is not working, messages are not sent.

So I want to ask you what is the best way to configure the mail service.

Thanks in advanced.

José


--
José David Cáceres
Ingeniero Ambiental
Máster en Tecnologías de la Información Geográfica



Mailtrack Remitente notificado con
Mailtrack 21/05/20 15:36:45
_______________________________________________
geonode-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-users


--

==

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information.
==
Ing. Alessio Fabiani

@alfa7691
Founder/Technical Lead


GeoSolutions S.A.S.
Via di Montramito 3/A - 55054  Massarosa (LU) - Italy
phone: +39 0584 962313
fax:     +39 0584 1660272
mob:   +39 331 6233686


http://www.geo-solutions.it
http://twitter.com/geosolutions_it
-------------------------------------------------------

Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.


This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.


_______________________________________________
geonode-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-users
Reply | Threaded
Open this post in threaded view
|

Re: Define email service on GeoNode

Jose Cáceres
Hi Alessio,

Thanks for your advice, I added the variables to the django image on the docker-compose file, without the quotation but I ended up with a 502 error on my site, removing those variables from the docker file let me have the site backup, so here is definitely something related to added those variables.

I'll keep working on it and see if I can find the problem.

Thanks,

José




Mailtrack Remitente notificado con
Mailtrack 22/05/20 10:54:34

On Fri, May 22, 2020 at 1:46 AM Alessio Fabiani <[hidden email]> wrote:
Hi Jose,
in GeoNode the recommended way is to use environment variables always.
There is logic on original settings which depends on some env values. That means that it is not simply matter to override a variable sometimes.

In your case I guess the error is that the values of end on docker-compose and uwsgi do not require quotes nor double quotes except in very special cases when you have characters that conflicts with the shell.

-A.



Il giorno gio 21 mag 2020 alle ore 23:38 Jose Cáceres <[hidden email]> ha scritto:
Hi,

I'm running Geonode on Docker.

I'm having troubles configuring the mail service for Geonode. I was able to have it up and running by defining the values directly on my settings.py file, like this:

EMAIL_ENABLE = ast.literal_eval(os.getenv('EMAIL_ENABLE', 'True'))

if EMAIL_ENABLE:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.smtp.EmailBackend')
    EMAIL_HOST = os.getenv('DJANGO_EMAIL_HOST', '
smtp.gmail.com')
    EMAIL_PORT = os.getenv('DJANGO_EMAIL_PORT', 587)
    EMAIL_HOST_USER = os.getenv('DJANGO_EMAIL_HOST_USER', '[hidden email]')
    EMAIL_HOST_PASSWORD = os.getenv('DJANGO_EMAIL_HOST_PASSWORD', 'mypassword')
    EMAIL_USE_TLS = ast.literal_eval(os.getenv('DJANGO_EMAIL_USE_TLS', 'True'))
    DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'GeoNode <[hidden email]>')
else:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.console.EmailBackend')


This way I was able to deliver messages to users, send notifications, etc.

But I don't want to have those values available on the settings.py, so I figure I could add the variales to my docker-compose file, like this:

DJANGO_EMAIL_HOST='smtp.gmail.com'
DJANGO_EMAIL_PORT=587
DJANGO_EMAIL_HOST_USER='[hidden email]'
DJANGO_EMAIL_HOST_PASSWORD='my password'


And I left the values on the settings.py by default:

EMAIL_ENABLE = ast.literal_eval(os.getenv('EMAIL_ENABLE', 'False'))

if EMAIL_ENABLE:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.smtp.EmailBackend')
    EMAIL_HOST = os.getenv('DJANGO_EMAIL_HOST', 'localhost')
    EMAIL_PORT = os.getenv('DJANGO_EMAIL_PORT', 25)
    EMAIL_HOST_USER = os.getenv('DJANGO_EMAIL_HOST_USER', '')
    EMAIL_HOST_PASSWORD = os.getenv('DJANGO_EMAIL_HOST_PASSWORD', '')
    EMAIL_USE_TLS = ast.literal_eval(os.getenv('DJANGO_EMAIL_USE_TLS', 'False'))
    DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'GeoNode <[hidden email]>')
else:
    EMAIL_BACKEND = os.getenv('DJANGO_EMAIL_BACKEND',
                              default='django.core.mail.backends.console.EmailBackend')


But this way is not working, messages are not sent.

So I want to ask you what is the best way to configure the mail service.

Thanks in advanced.

José


--
José David Cáceres
Ingeniero Ambiental
Máster en Tecnologías de la Información Geográfica



Mailtrack Remitente notificado con
Mailtrack 21/05/20 15:36:45
<img width="0" height="0" alt="" style="display: flex;" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">
_______________________________________________
geonode-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-users


--

==

GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information.
==
Ing. Alessio Fabiani

@alfa7691
Founder/Technical Lead


GeoSolutions S.A.S.
Via di Montramito 3/A - 55054  Massarosa (LU) - Italy
phone: +39 0584 962313
fax:     +39 0584 1660272
mob:   +39 331 6233686


http://www.geo-solutions.it
http://twitter.com/geosolutions_it
-------------------------------------------------------

Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia.


This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail.



--
José David Cáceres
Ingeniero Ambiental
Máster en Tecnologías de la Información Geográfica

_______________________________________________
geonode-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/geonode-users