pipeline.src.helpers.emails =========================== .. py:module:: pipeline.src.helpers.emails Functions --------- .. autoapisummary:: pipeline.src.helpers.emails.create_html_email pipeline.src.helpers.emails.create_sms_email pipeline.src.helpers.emails.create_fax_email pipeline.src.helpers.emails.send_email pipeline.src.helpers.emails.send_sms pipeline.src.helpers.emails.send_fax pipeline.src.helpers.emails.send_email_or_sms_or_fax_message pipeline.src.helpers.emails.resize_pdf_to_A4 Module Contents --------------- .. py:function:: create_html_email(to: Union[str, List[str]], subject: str, html: str, from_: str = MONITORFISH_EMAIL_ADDRESS, cc: Union[str, List[str]] = None, bcc: Union[str, List[str]] = None, images: List[pathlib.Path] = None, attachments: List[Tuple[str, bytes]] = None, reply_to: str = None) -> email.message.EmailMessage Creates a `email.EmailMessage` with the defined parameters. :param to: email address or list of email addresses of recipient(s) :type to: Union[str, List[str]] :param subject: Subject of the email. :type subject: str :param html: html representation of the email's content. :type html: str :param from_: `From` field. Defaults to env var `MONITORFISH_EMAIL_ADDRESS`. :type from_: str, optional :param cc: `Cc` field with optional email address :type cc: Union[str, List[str]], optional :param (or list of email addresses) of copied recipient: :type (or list of email addresses) of copied recipient: s :param bcc: `Bcc` field with optional email address :type bcc: Union[str, List[str]], optional :param (or list of email addresses) of hidden copied recipient: :type (or list of email addresses) of hidden copied recipient: s :param from_: `From` field. Defaults to MONITORFISH_EMAIL_ADDRESS env var. :type from_: str, optional :param images: List of `Path` to images on the server's file system to attach to the email. These images can be displayed in the html body of the email by referencing them in the `src` attribute of an `` tag as `cid:`, where `` is the image file's name. For example: `/a/b/c/my_image_123.png` can be included in the html message as : `` in the html message. Defaults to None. :type images: List[Path], optional :param attachments: `list` of attachments to add to the email. Elements of the list must be pairs of (filename, content). Defaults to None. :type attachments: List[Tuple[str, bytes]], optional :param reply_to: if given, added as `Reply-To` header. Defaults to None. :type reply_to: str, optional :returns: EmailMessage .. py:function:: create_sms_email(to: Union[str, List[str]], text: str, from_: str = MONITORFISH_EMAIL_ADDRESS) -> email.message.EmailMessage Creates a `email.EmailMessage` with the defined parameters, configured to be sent as an SMS. :param to: phone number or list of phone numbers of recipient(s) :type to: Union[str, List[str]] :param text: text of the SMS message :type text: str :param from_: `From` field. Defaults to MONITORFISH_EMAIL_ADDRESS env var. :type from_: str, optional :returns: EmailMessage .. py:function:: create_fax_email(to: Union[str, List[str]], pdf: bytes, from_: str = MONITORFISH_EMAIL_ADDRESS) -> email.message.EmailMessage Creates a `email.EmailMessage` with the defined parameters. :param to: email address or list of email addresses of recipient(s) :type to: Union[str, List[str]] :param pdf: `bytes` pdf object :type pdf: bytes :param from_: `From` field. Defaults to MONITORFISH_EMAIL_ADDRESS env var. :type from_: str, optional :returns: EmailMessage .. py:function:: send_email(msg: email.message.EmailMessage) -> dict Sends input email using the contents of `From` header as sender and `To`, `Cc` and `Bcc` headers as recipients. This method will return normally if the mail is accepted for at least one recipient. It returns a dictionary, with one entry for each recipient that was refused. Each entry contains a tuple of the SMTP error code and the accompanying error message sent by the server, like : { "three@three.org" : ( 550 ,"User unknown" ) } :param msg: `email.message.EmailMessage` to send. :type msg: EmailMessage :returns: {email_address : (error_code, error_message)} for all recipients that were refused. :rtype: dict :raises SMTPHeloError: The server didn't reply properly to the helo greeting. :raises SMTPRecipientsRefused: The server rejected ALL recipients (no mail was sent). :raises SMTPSenderRefused: The server didn't accept the from_addr. :raises SMTPDataError: The server replied with an unexpected error code (other than a refusal of a recipient). :raises SMTPNotSupportedError: The mail_options parameter includes 'SMTPUTF8' but the SMTPUTF8 extension is not supported by the server. :raises ValueError: if there is more than one set of 'Resent-' headers .. py:function:: send_sms(msg: email.message.EmailMessage) -> dict Same as `send_email`, using sms server. .. py:function:: send_fax(msg: email.message.EmailMessage) -> dict Same as `send_email`, using fax server. .. py:function:: send_email_or_sms_or_fax_message(msg: email.message.EmailMessage, communication_means: src.entities.communication_means.CommunicationMeans, is_integration: bool, logger: logging.Logger) -> dict .. py:function:: resize_pdf_to_A4(pdf: bytes) -> bytes