alert_email_job(ctx, user, data)
async
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
Source code in src/mmisp/worker/jobs/email/alert_email_job.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
contact_email_job(ctx, requester, data)
async
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
Source code in src/mmisp/worker/jobs/email/contact_email_job.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
posts_email_job(ctx, user, data)
async
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
Source code in src/mmisp/worker/jobs/email/posts_email_job.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|
AlertEmailData
Bases: BaseModel
Encapsulates the necessary data to send and create an alert email.
Source code in src/mmisp/worker/jobs/email/job_data.py
6 7 8 9 10 11 12 13 14 15 16 |
|
event_id
instance-attribute
The id of the event which triggered the alert
old_publish
instance-attribute
The timestamp of old publishing
receiver_ids
instance-attribute
The ids of the receivers
ContactEmailData
Bases: BaseModel
Encapsulates the necessary data to send and create a contact email.
Source code in src/mmisp/worker/jobs/email/job_data.py
19 20 21 22 23 24 25 26 27 28 29 |
|
event_id
instance-attribute
The id of the event which the user wants to know more about
message
instance-attribute
The custom message of the user
receiver_ids
instance-attribute
The ids of the receivers
PostsEmailData
Bases: BaseModel
Encapsulates the necessary data to send and create a posts email.
Source code in src/mmisp/worker/jobs/email/job_data.py
32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
message
instance-attribute
The message which was posted at the post
post_id
instance-attribute
The id of the post where something new was posted
receiver_ids
instance-attribute
The ids of the receivers
title
instance-attribute
The title of the post
SmtpClient
Provides methods to build an SMTP connection to send emails.
Source code in src/mmisp/worker/jobs/email/utility/smtp_client.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
__init__(host, port)
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
Source code in src/mmisp/worker/jobs/email/utility/smtp_client.py
14 15 16 17 18 19 20 21 22 |
|
close_smtp_connection()
Closes the SMTP Connection.
Source code in src/mmisp/worker/jobs/email/utility/smtp_client.py
53 54 55 56 57 |
|
open_smtp_connection(email, password)
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
Source code in src/mmisp/worker/jobs/email/utility/smtp_client.py
24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
send_email(from_addr, to_addr, email)
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
Source code in src/mmisp/worker/jobs/email/utility/smtp_client.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
EmailConfigData
Bases: BaseSettings
Encapsulates configuration for the email worker and its jobs.
Source code in src/mmisp/worker/jobs/email/utility/email_config_data.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
email_subject_string = Field('tlp', validation_alias=ENV_EMAIL_SUBJECT_STRING)
class-attribute
instance-attribute
The tlp string to search for an email subject
mmisp_email_address = Field('misp@localhost', validation_alias=ENV_EMAIL_ADDRESS)
class-attribute
instance-attribute
The email of MISP
mmisp_email_password = Field('', validation_alias=ENV_EMAIL_PASSWORD)
class-attribute
instance-attribute
The password of the MISP email
mmisp_email_username = Field('misp', validation_alias=ENV_EMAIL_USERNAME)
class-attribute
instance-attribute
The username of the MISP email
mmisp_smtp_host = Field('localhost', validation_alias=ENV_SMTP_HOST)
class-attribute
instance-attribute
The host of the SMTP server
mmisp_smtp_port = Field(25, validation_alias=ENV_SMTP_PORT)
class-attribute
instance-attribute
The port of the SMTP server
mmisp_url = Field('http://127.0.0.1', validation_alias=ENV_URL)
class-attribute
instance-attribute
The url of MISP
UtilityEmail
Provides functionality to built emails.
Source code in src/mmisp/worker/jobs/email/utility/utility_email.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
get_email_subject_mark_for_event(event, email_subject_string)
staticmethod
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
Source code in src/mmisp/worker/jobs/email/utility/utility_email.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
send_emails(misp_api, misp_email_address, email_username, email_password, smtp_port, smtp_host, receiver_ids, email_msg)
async
staticmethod
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
Source code in src/mmisp/worker/jobs/email/utility/utility_email.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|