HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/mandrill.cpython-310.pyc
o

�N�g:�@s�dZddlZddlZddlZzddlZdZWney!dZYnwdZe�	e
�ZdZdZ
dd	�Zd
d�Zddd
�Zdd�Zdd�Zddd�Z						ddd�ZdS)a&
Mandrill
========

Send out emails using the Mandrill_ API_.

.. _Mandrill: https://mandrillapp.com
.. _API: https://mandrillapp.com/api/docs/

In the minion configuration file, the following block is required:

.. code-block:: yaml

  mandrill:
    key: <API_KEY>

.. versionadded:: 2018.3.0
�NTF�mandrillzhttps://mandrillapp.com/api�cCstdurdStS)z2
    Return the execution module virtualname.
    F)FzIThe requests python package is required for the mandrill execution module)�HAS_REQUESTS�__virtualname__�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/mandrill.py�__virtual__(srcCsdddd�S)z&
    Default dictionary returned.
    F�N)�result�comment�outrrrrr�_default_ret4sr
cCsFtdd�}|s
i}|p|�d�pt|p|�d�|p |�d�p td�S)z7
    Retrieve the API params from the config file.
    zconfig.merger�api_url�key�api_version)r�api_keyr)Z__salt__�get�BASE_URL�DEFAULT_VERSION)rrrZmandrill_cfgrrr�_get_api_params;s��rcCsdj|t|�|d�S)z
    Build the API URL.
    z{url}/{version}/{method}.json)�url�version�method)�format�float)rrrrrr�_get_urlKs
�rcCs
ddd�S)z<
    Return HTTP headers required for the Mandrill API.
    zapplication/jsonzMandrill-Python/1.0.57)zcontent-typez
user-agentrrrrr�_get_headersTs
rcCs�|st�}t��}t�d|�|j||tjj�	|�d�}|��}t
�}t�d|j�t�d�t�|�|jdkrY|jdkrL|�dd�|d	<||d
<|S|�
d	|�dd�i�|S|�
d|��d
��|S)zE
    Make the HTTP request and return the body as python object.
    zQuerying %s)�headers�datazStatus code: %dzResponse body:��i��messager	rr�errorT)r
r)r�requests�session�log�debugZpost�salt�utils�json�dumpsr
Zstatus_code�pop�updater)rrrr#ZreqZreq_body�retrrr�
_http_request[s&



r-c
CsDt|||d�}td|d|dd�}|d||||d�}	t||	d�S)	a�
    Send out the email using the details from the ``message`` argument.

    message
        The information on the message to send. This argument must be
        sent as dictionary with at fields as specified in the Mandrill API
        documentation.

    asynchronous: ``False``
        Enable a background sending mode that is optimized for bulk sending.
        In asynchronous mode, messages/send will immediately return a status of
        "queued" for every recipient. To handle rejections when sending in asynchronous
        mode, set up a webhook for the 'reject' event. Defaults to false for
        messages with no more than 10 recipients; messages with more than 10
        recipients are always sent asynchronously, regardless of the value of
        asynchronous.

    ip_pool
        The name of the dedicated ip pool that should be used to send the
        message. If you do not have any dedicated IPs, this parameter has no
        effect. If you specify a pool that does not exist, your default pool
        will be used instead.

    send_at
        When this message should be sent as a UTC timestamp in
        ``YYYY-MM-DD HH:MM:SS`` format. If you specify a time in the past,
        the message will be sent immediately. An additional fee applies for
        scheduled email, and this feature is only available to accounts with a
        positive balance.

    .. note::
        Fur further details please consult the `API documentation <https://mandrillapp.com/api/docs/messages.dart.html>`_.

    CLI Example:

    .. code-block:: bash

        salt '*' mandrill.send message="{'subject': 'Hi', 'from_email': 'test@example.com', 'to': [{'email': 'recv@example.com', 'type': 'to'}]}"

    ``message`` structure example (as YAML for readability):

    .. code-block:: yaml

        message:
            text: |
                This is the body of the email.
                This is the second line.
            subject: Email subject
            from_name: Test At Example Dot Com
            from_email: test@example.com
            to:
              - email: recv@example.com
                type: to
                name: Recv At Example Dot Com
              - email: cc@example.com
                type: cc
                name: CC At Example Dot Com
            important: true
            track_clicks: true
            track_opens: true
            attachments:
              - type: text/x-yaml
                name: yaml_file.yml
                content: aV9hbV9zdXBlcl9jdXJpb3VzOiB0cnVl

    Output example:

    .. code-block:: bash

        minion:
            ----------
            comment:
            out:
                |_
                  ----------
                  _id:
                      c4353540a3c123eca112bbdd704ab6
                  email:
                      recv@example.com
                  reject_reason:
                      None
                  status:
                      sent
            result:
                True
    )rrrz
messages/sendrr)rrr)rr �async�ip_pool�send_at)r)rrr-)
r Zasynchronousr/r0rrr�paramsrrrrr�sendys_��r2)NNN)NN)FNNNNN)�__doc__�loggingZsalt.utils.jsonr&Zsalt.utils.versionsr"r�ImportErrorr�	getLogger�__file__r$rrrr
rrrr-r2rrrr�<module>s6�

	
 �