Skip to content
Snippets Groups Projects
Verified Commit f1e313db authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Add mail recipient to oss params

parent 01016f7a
No related branches found
No related tags found
No related merge requests found
......@@ -90,7 +90,8 @@
"smtp_port": 487,
"starttls_enabled": true,
"smtp_username": "username",
"smtp_password": "password"
"smtp_password": "password",
"notification_email_destinations": "oc@nren.local, neteng@nren.local, ceo@nren.local"
},
"SHAREPOINT": {
"client_id": "UUID",
......
......@@ -7,19 +7,19 @@ from ssl import create_default_context
from gso.settings import load_oss_params
def send_mail(recipient: str, subject: str, body: str) -> None:
"""Send an email message to the given address.
def send_mail(recipients: str, subject: str, body: str) -> None:
"""Send an email message to the given addresses.
Only supports STARTTLS, not SSL.
:param str recipient: The destination address.
:param str recipients: The destination addresses, comma separated.
:param str subject: The email subject.
:param str body: The contents of the email message.
"""
email_params = load_oss_params().EMAIL
msg = EmailMessage()
msg["From"] = email_params.from_address
msg["To"] = recipient
msg["To"] = recipients
msg["Subject"] = subject
msg.set_content(body)
......
......@@ -11,12 +11,13 @@ import os
from pathlib import Path
from typing import Annotated
from pydantic import Field
from pydantic import EmailStr, Field
from pydantic_forms.types import UUIDstr
from pydantic_settings import BaseSettings
from typing_extensions import Doc
from gso.products.product_blocks.site import SiteTier
from gso.utils.shared_enums import PortNumber
logger = logging.getLogger(__name__)
......@@ -152,13 +153,15 @@ class NetBoxParams(BaseSettings):
class EmailParams(BaseSettings):
"""Parameters for the email service."""
# TODO: Use more strict types after we've migrated to Pydantic 2.x
from_address: str
from_address: EmailStr
smtp_host: str
smtp_port: int
smtp_port: PortNumber
starttls_enabled: bool
smtp_username: str | None = None
smtp_password: str | None = None
#: List of email addresses that should receive notifications when validation of a subscription fails.
#: Can be a comma-separated list of multiple addresses.
notification_email_destinations: str
class SharepointParams(BaseSettings):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment