alert_email_job
async
alert_email_job(ctx: WrappedContext[None], user: UserData, data: AlertEmailData) -> None
prepares an alert email by filling and rendering a template. afterward it will be sent to all specified users. :param user: the user who requested the job :type user: UserData :param data: contains data for the template and the user ids who will receive the emails. :type data: AlertEmailData
contact_email_job
async
contact_email_job(ctx: WrappedContext[None], requester: UserData, data: ContactEmailData) -> None
Prepares a contact email by filling and rendering a template. Afterward it will be sent to all specified users. :param requester: is the user who wants to contact the users :type requester: UserData :param data: contains data for the template and the user ids who will receive the emails. :type data: ContactEmailData
posts_email_job
async
posts_email_job(ctx: WrappedContext[None], user: UserData, data: PostsEmailData) -> None
Prepares a posts email by filling and rendering a template. Afterward it will be sent to all specified users. :param user: the user who requested the job :type user: UserData :param data: contains data for the template and the user ids who will receive the emails. :type data: PostsEmailData
AlertEmailData
Bases: BaseModel
Encapsulates the necessary data to send and create an alert email.
event_id
instance-attribute
event_id: int
The id of the event which triggered the alert
old_publish
instance-attribute
old_publish: datetime
The timestamp of old publishing
receiver_ids
instance-attribute
receiver_ids: list[int]
The ids of the receivers
ContactEmailData
Bases: BaseModel
Encapsulates the necessary data to send and create a contact email.
event_id
instance-attribute
event_id: int
The id of the event which the user wants to know more about
message
instance-attribute
message: str
The custom message of the user
receiver_ids
instance-attribute
receiver_ids: list[int]
The ids of the receivers
PostsEmailData
Bases: BaseModel
Encapsulates the necessary data to send and create a posts email.
message
instance-attribute
message: str
The message which was posted at the post
post_id
instance-attribute
post_id: int
The id of the post where something new was posted
receiver_ids
instance-attribute
receiver_ids: list[int]
The ids of the receivers
title
instance-attribute
title: str
The title of the post
SmtpClient
Provides methods to build an SMTP connection to send emails.
__init__
__init__(host: str, port: int) -> None
Initializes a new SMTP object. :param port: is the port of the SMTP server :type port: int :param host: is the host of the SMTP server :type host: str
close_smtp_connection
close_smtp_connection() -> None
Closes the SMTP Connection.
open_smtp_connection
open_smtp_connection(email: str, password: str) -> None
Connects to the SMTP server and logs in with the misp email. If no password is given, the connection will be established without a password. :param email: is the email of misp :type email: str :param password: is the password of the email :type password: str
send_email
send_email(from_addr: str, to_addr: str, email: str) -> None
Sends an email. :param from_addr: is the address of the sender (misp email9 :type from_addr: str :param to_addr: is the address of the receiver (user) :type to_addr: str :param email: is the content of the email :type email: str
EmailConfigData
Bases: BaseSettings
Encapsulates configuration for the email worker and its jobs.
email_subject_string
class-attribute
instance-attribute
email_subject_string: str = Field('tlp', validation_alias=ENV_EMAIL_SUBJECT_STRING)
The tlp string to search for an email subject
mmisp_email_address
class-attribute
instance-attribute
mmisp_email_address: str = Field('misp@localhost', validation_alias=ENV_EMAIL_ADDRESS)
The email of MISP
mmisp_email_password
class-attribute
instance-attribute
mmisp_email_password: str = Field('', validation_alias=ENV_EMAIL_PASSWORD)
The password of the MISP email
mmisp_email_username
class-attribute
instance-attribute
mmisp_email_username: str = Field('misp', validation_alias=ENV_EMAIL_USERNAME)
The username of the MISP email
mmisp_smtp_host
class-attribute
instance-attribute
mmisp_smtp_host: str = Field('localhost', validation_alias=ENV_SMTP_HOST)
The host of the SMTP server
mmisp_smtp_port
class-attribute
instance-attribute
mmisp_smtp_port: NonNegativeInt = Field(25, validation_alias=ENV_SMTP_PORT)
The port of the SMTP server
mmisp_url
class-attribute
instance-attribute
mmisp_url: str = Field('http://127.0.0.1', validation_alias=ENV_URL)
The url of MISP
UtilityEmail
Provides functionality to built emails.
get_email_subject_mark_for_event
staticmethod
get_email_subject_mark_for_event(event: AddEditGetEventDetails, email_subject_string: str) -> str
Returns the tlp tag of the given event as a subject for emails.
:param event: the event to get the subject for :type event: AddEditGetEventDetails :param email_subject_string: is the tlp string to search :type email_subject_string: str :return: the tlp tag of the event :rtype: str
send_emails
async
staticmethod
send_emails(misp_api: MispAPI, misp_email_address: str, email_username: str, email_password: str, smtp_port: int, smtp_host: str, receiver_ids: list[int], email_msg: EmailMessage) -> None
Sends emails to the given users by opening an SMTP connection
:param misp_email_address: is the email of misp :type misp_email_address: str :param email_username: is the username of misp :type email_username: str :param email_password: is the password of misp :type email_password: str :param smtp_port: is the port of the SMTP server :type smtp_port: int :param smtp_host: is the host of the SMTP server :type smtp_host: str :param receiver_ids: are the ids of the users who get the email :type receiver_ids: list[int] :param email_msg: is the email which will be sent :type email_msg: EmailMessage