Mail Controller

class genomcore.controllers.email.EmailController(*args, **kwargs)

Bases: BaseController

MODE_GENERIC = 'generic'
TPL_DEFAULT = 'DEFAULT'
TPL_EXISTENT_CUSTOMER = 'EXISTENT_CUSTOMER'
TPL_PARTNER_CUSTOMER = 'PARTNER_CUSTOMER'
TPL_NEW_CUSTOMER_BASE = 'NEW_CUSTOMER_BASE'
TPL_EXISTENT_CUSTOMER_BASE = 'EXISTENT_CUSTOMER_BASE'
TPL_RESET_PASSWORD = 'RESET_PASSWORD'
TPL_PRE_ORDER = 'PRE_ORDER'
TPL_LOGISTIC_SERVICE = 'LOGISTIC_SERVICE'
TPLS = ['DEFAULT', 'EXISTENT_CUSTOMER', 'PARTNER_CUSTOMER', 'NEW_CUSTOMER_BASE', 'EXISTENT_CUSTOMER_BASE', 'RESET_PASSWORD', 'PRE_ORDER', 'LOGISTIC_SERVICE']

Mail controller to send emails.

_build_attachments(files)

Build the attachments list for the email payload.

Reads each file from disk, encodes its content as base64, and infers the MIME type from the file extension.

Parameters:

files – List of file paths (str or Path) to attach. May be None or empty.

Returns:

  • filename: The file name (without path).

  • content: File contents encoded in base64.

  • type: MIME type (e.g. “application/pdf”).

  • disposition: “attachment”.

Return type:

List of dicts ready to be passed to EmailSchema, each containing

send_genomcore(mails: List[str], mail_subject: str, mail_body: str, files=None) Dict[str, Any] | Response

Send email.

Given a list of mail receivers, a mail subject and body, it send a Biomed email through SendGrid API.

Parameters:
  • mails (List[str]) – List of mail receivers

  • mail_subject (str) – Mail subject

  • mail_body (str) – Mail body

  • files (List[str]) – it is a list path to send by mail

Returns:

email API response

Return type:

Union[Dict[str, Any], Response]

__annotations__ = {}
__firstlineno__ = 17
__static_attributes__ = ('_notifications_requester', '_requester')
send(mails, mail_subject, mail_body, files=None, template=None, mail_alias=None, mode='generic')

Send email.

if mode argument is EmailController.MODE_GENERIC:

Given a list of mail receivers, a mail subject and body, it send a Biomed email through SendGrid API. Generic emails (basically for feedback within apps/workflows) Args:

mails(List[str]): List of mail receivers mail_subject(str): Mail subject mail_body(str): Mail body mode: EmailController.MODE_GENERIC, option by default files(List[str]): it is a list path to send by mail

if mode argument is EmailController.MODE_SENDGRID:

Send an e-mail with SendGrid with the Made Of Genes template. Args:

mode: EmailController.MODE_SENDGRID mails(str)): mail receiver mail_body(List[str]): Mail body mail_alias(Optional[str]): template(Optional[str]): Its a defined const with next values: TPL_DEFAULT,TPL_EXISTENT_CUSTOMER,TPL_PARTNER_CUSTOMER,TPL_NEW_CUSTOMER_BASE,

TPL_EXISTENT_CUSTOMER_BASE,TPL_RESET_PASSWORD,TPL_PRE_ORDER,TPL_LOGISTIC_SERVICE

Returns:

email API response

Return type:

Union[Dict[str, Any], Response]