Эх сурвалжийг харах

HUE-8888 [core] Support for SendGrid email backend

Romain 6 жил өмнө
parent
commit
fb98cd8577

+ 0 - 6
desktop/core/src/desktop/conf.py

@@ -616,21 +616,18 @@ SMTP = ConfigSection(
       type=str,
       type=str,
       default="localhost"
       default="localhost"
     ),
     ),
-
     PORT = Config(
     PORT = Config(
       key="port",
       key="port",
       help=_("The SMTP server port."),
       help=_("The SMTP server port."),
       type=int,
       type=int,
       default=25
       default=25
     ),
     ),
-
     USER = Config(
     USER = Config(
       key="user",
       key="user",
       help=_("The username for the SMTP host."),
       help=_("The username for the SMTP host."),
       type=str,
       type=str,
       default=""
       default=""
     ),
     ),
-
     PASSWORD = Config(
     PASSWORD = Config(
       key="password",
       key="password",
       help=_("The password for the SMTP user."),
       help=_("The password for the SMTP user."),
@@ -638,7 +635,6 @@ SMTP = ConfigSection(
       private=True,
       private=True,
       default="",
       default="",
     ),
     ),
-
     PASSWORD_SCRIPT = Config(
     PASSWORD_SCRIPT = Config(
       key="password_script",
       key="password_script",
       help=_("Execute this script to produce the SMTP user password. This will be used when the SMTP `password` is not set."),
       help=_("Execute this script to produce the SMTP user password. This will be used when the SMTP `password` is not set."),
@@ -646,14 +642,12 @@ SMTP = ConfigSection(
       private=True,
       private=True,
       default="",
       default="",
     ),
     ),
-
     USE_TLS = Config(
     USE_TLS = Config(
       key="tls",
       key="tls",
       help=_("Whether to use a TLS (secure) connection when talking to the SMTP server."),
       help=_("Whether to use a TLS (secure) connection when talking to the SMTP server."),
       type=coerce_bool,
       type=coerce_bool,
       default=False
       default=False
     ),
     ),
-
     DEFAULT_FROM= Config(
     DEFAULT_FROM= Config(
       key="default_from_email",
       key="default_from_email",
       help=_("Default email address to use for various automated notifications from Hue."),
       help=_("Default email address to use for various automated notifications from Hue."),

+ 5 - 0
desktop/core/src/desktop/settings.py

@@ -449,6 +449,11 @@ EMAIL_HOST_PASSWORD = desktop.conf.get_smtp_password()
 EMAIL_USE_TLS = desktop.conf.SMTP.USE_TLS.get()
 EMAIL_USE_TLS = desktop.conf.SMTP.USE_TLS.get()
 DEFAULT_FROM_EMAIL = desktop.conf.SMTP.DEFAULT_FROM.get()
 DEFAULT_FROM_EMAIL = desktop.conf.SMTP.DEFAULT_FROM.get()
 
 
+if EMAIL_BACKEND == 'sendgrid_backend.SendgridBackend':
+  SENDGRID_API_KEY = desktop.conf.get_smtp_password()
+  SENDGRID_SANDBOX_MODE_IN_DEBUG = DEBUG
+
+
 # Used for securely creating sessions. Should be unique and not shared with anybody. Changing auth backends will invalidate all open sessions.
 # Used for securely creating sessions. Should be unique and not shared with anybody. Changing auth backends will invalidate all open sessions.
 SECRET_KEY = desktop.conf.get_secret_key()
 SECRET_KEY = desktop.conf.get_secret_key()
 if SECRET_KEY:
 if SECRET_KEY: