How to use mailsuite - 3 common examples

To help you get started, we’ve selected a few mailsuite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github domainaware / parsedmarc / parsedmarc / __init__.py View on Github external
def idle_callback(connection):
        res = get_dmarc_reports_from_inbox(connection=connection,
                                           reports_folder=reports_folder,
                                           archive_folder=archive_folder,
                                           delete=delete,
                                           test=test,
                                           offline=offline,
                                           nameservers=nameservers,
                                           dns_timeout=dns_timeout,
                                           strip_attachment_payloads=sa)
        callback(res)

    while True:
        try:
            IMAPClient(host=host, username=username, password=password,
                       port=port, ssl=ssl, verify=verify,
                       initial_folder=reports_folder,
                       idle_callback=idle_callback,
                       idle_timeout=idle_timeout)
        except timeout:
            logger.warning("IMAP connection timeout. Reconnecting...")
github domainaware / parsedmarc / parsedmarc / __init__.py View on Github external
aggregate_reports = []
    forensic_reports = []
    aggregate_report_msg_uids = []
    forensic_report_msg_uids = []
    aggregate_reports_folder = "{0}/Aggregate".format(archive_folder)
    forensic_reports_folder = "{0}/Forensic".format(archive_folder)
    invalid_reports_folder = "{0}/Invalid".format(archive_folder)

    if results:
        aggregate_reports = results["aggregate_reports"].copy()
        forensic_reports = results["forensic_reports"].copy()

    if connection:
        server = connection
    else:
        server = IMAPClient(host, user, password, port=port,
                            ssl=ssl, verify=verify,
                            timeout=timeout,
                            max_retries=max_retries,
                            initial_folder=reports_folder)

    server.create_folder(archive_folder)
    server.create_folder(aggregate_reports_folder)
    server.create_folder(forensic_reports_folder)
    server.create_folder(invalid_reports_folder)

    messages = server.search()
    total_messages = len(messages)
    logger.debug("Found {0} messages in {1}".format(len(messages),
                                                    reports_folder))
    for i in range(len(messages)):
        msg_uid = messages[i]
github domainaware / parsedmarc / parsedmarc / __init__.py View on Github external
if not attachment_filename.lower().endswith(".zip"):
            attachment_filename += ".zip"
        filename = attachment_filename
    else:
        filename = "DMARC-{0}.zip".format(date_string)

    assert isinstance(mail_to, list)

    if subject is None:
        subject = "DMARC results for {0}".format(date_string)
    if message is None:
        message = "DMARC results for {0}".format(date_string)
    zip_bytes = get_report_zip(results)
    attachments = [(filename, zip_bytes)]

    send_email(host, mail_from, mail_to, message_cc=mail_cc,
               message_bcc=mail_bcc, port=port,
               require_encryption=require_encryption, verify=verify,
               username=username, password=password, subject=subject,
               attachments=attachments, plain_message=message)

mailsuite

A Python package for retrieving, parsing, and sending emails

Apache-2.0
Latest version published 29 days ago

Package Health Score

63 / 100
Full package analysis

Similar packages